How can I programatically parse the names of functions, arguments, and their return values?
I am interested in generating workplan dataframes for automating R data analysis workflows with the drake
package. One can generate such workplan dataframes with the workplan
function.
I have an R script with functions that I would like to use. For example:
funA <- function(x){
y <- x + 2
y
}
funB <- function(y){
z <- y^2
z
}
And I would like to programmatically generate a dataframe like the one below. How can I parse function names, arguments, and return values, and create a data.frame like this, either with drake::workplan
, or with other function?
target command
1 y funA(5)
2 z funB(3)
One would do this by hand like this:
my_plan <- drake::workplan(z=funB(5), y=funA(3))
And then run the workflow with:
drake::make(my_plan)
Thank you.