...@gmail.com]
Sent: Monday, February 08, 2010 6:01 AM
To: christophe dutang
Cc: r-help@r-project.org
Subject: Re: [R] the hat ^ in regular expression
Try this:
library(gsubfn)
myexpr - expression( ( mydata$variable1 / mydata$variable2 ) ^ 2 - 1
+ 3 * 4) strapply(as.character(myexpr), mydata
Dear UseRs,
I'm trying to find variable names (string after the mydata$) in a
expression. For example,
myexpr - expression( ( mydata$variable1 / mydata$variable2 ) ^ 2 - 1 + 3 *
4 )
I would like to get variable1 and variable2. The following few lines
split the original character string into
christophe dutang wrote:
Dear UseRs,
I'm trying to find variable names (string after the mydata$) in a
expression. For example,
myexpr - expression( ( mydata$variable1 / mydata$variable2 ) ^ 2 - 1 + 3 *
4 )
I would like to get variable1 and variable2. The following few lines
split the
Try this:
library(gsubfn)
myexpr - expression( ( mydata$variable1 / mydata$variable2 ) ^ 2 - 1 + 3 * 4)
strapply(as.character(myexpr), mydata\\$(\\w+))[[1]]
[1] variable1 variable2
See http://gsubfn.googlecode.com for more info on strapply.
Another approach is
setdiff(all.vars(myexpr),
4 matches
Mail list logo