An improvement on my suggestion using codetools is to use
codetools::findGlobals(f, merge=FALSE)
which separates the functions and variables:
$functions
[1] "*" "cos"
$variables
[1] "omega" "rho"
This is important, because R distinguishes between functions and
variables by usage when it is
2011/3/24 Javier López-de-Lacalle :
> Hi everybody:
>
> I need to get the names of the arguments in an object of class "expression".
> I've got the following expression:
>
>> x <- expression(rho * cos(omega))
>
> Is there any function or procedure that returns the names of the arguments
> (in the e
I tried this as an exercise and here's what I arrived to:
collector <- function(expr){
RES <- list()
foo <- function(x) unlist(lapply(x, as.list))
EXPR <- foo(expr)
while(length(EXPR) >0){
if(is.symbol(EXPR[[1]])){
RES <- c(RES, EXPR[[1]])
EXPR <- EXPR[-1
On 11-03-24 5:03 AM, Javier López-de-Lacalle wrote:
Hi everybody:
I need to get the names of the arguments in an object of class "expression".
I've got the following expression:
x<- expression(rho * cos(omega))
Is there any function or procedure that returns the names of the arguments
(in th
Hi everybody:
I need to get the names of the arguments in an object of class "expression".
I've got the following expression:
> x <- expression(rho * cos(omega))
Is there any function or procedure that returns the names of the arguments
(in the example: "rho" and "omega")?
I tried a rough appro
5 matches
Mail list logo