Re: [R] Extract function parameters from a R expression

2018-06-20 Thread Gabor Grothendieck
If you specifically want to know which packages were loaded by the script then using a vanilla version of R (i.e. one where only base packages are loaded): vanilla_search <- search() source("myRprg.R") setdiff(search(), vanilla_search) On Wed, Jun 20, 2018 at 4:08 AM, Sigbert Klinke

Re: [R] Extract function parameters from a R expression

2018-06-20 Thread Bert Gunter
... or if the argument is just quoted text or a numeric value as in your library() example, don't parse the text and use regex's to search for the function call and pick out the text of the arguments. Again, this only works (I think) for the simple sort of case of your example. Beyond that,

Re: [R] Extract function parameters from a R expression

2018-06-20 Thread Hadley Wickham
You need to recursively walk the parse tree/AST. See, e.g., https://adv-r.hadley.nz/expressions.html#ast-funs Hadley On Wed, Jun 20, 2018 at 10:08 AM, Sigbert Klinke wrote: > Hi, > > I have read an R program with > > expr <- parse("myRprg.R") > > How can I extract the parameters of a specifc R