Hi everyone,

This may be very simple but I couldn't figure it out. I have this function

rsm.lm<-function(data,xvar='xCmin',yvar='yCmin') {

 #some calculation......

 recast(df, xvar~yvar, id.var=1:2, measure.var=3)
 #some other operations
}

df is a dataframe defined internally within the function with two id
variables (xCmin and yCmin) and a measure variable. recast doesn't work and
keep saying "Casting formula contains variables not found in molten data:
xvar, yvar......"

I tried

as.name(xvar)~as.name(yvar)
get(xvar)~get(yvar)
cat(xvar)~cat(yvar)
eval(cat(xvar))~eval(cat(yval))

But none of these works. It only works when I explicitly specify the
formula as

recast(df, xCmin~yCmin, id.var=1:2, measure.var=3)

Is there a workaround this issue? Thanks.

Jun

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to