in an application I use RODBC to access a database. Specifically I call a function like this: sqlQuery(conn, qry), where qry is a string, and conn is a RODBC connection object.
Is it possible to paste this into a file in such a way that if I copy and paste the file contents into the terminal, I will reproduce the exact function call?
For example, if I make a dataframe: df <- data.frame(test = c(1, 2, 3)), I can call dput(df), which will return: structure(list(frank = c(1, 2, 3)), class = "data.frame", row.names = c(NA, -3L))
If I copy and paste that into the terminal, I will get the original dataframe.
It would be really convienient for debugging if I could do something like this for sqlQuery(conn, qry)
Assuming that
dputworks Ok for your objects, and that we can assume that any required libraries are loaded and/or functions defined, why not just build the function call string like this:Define 'fput' function to generate pastable string that will replicate a function call:
Example:
Sample data:
Sample function call to replicate as pastable string:
Call fput():
Output:
Check: copy-paste of output generates same result as plot(a,b)