-roger
RenE J.V. Bertin wrote:
Hello,
I'm having a little argument with the 'with' function. I have
aov.SS1 <- function( y, indep=speed, fSnr=Subject, ... ) { indep <- factor(speed) fSnr <- factor(fSnr) ## .... }
and a dataframe containing speed, Subject, and a bunch of other columns. If I now do
with( data, aov.SS1( y=Obs ) )
I get a message
Error in factor(indep) : Object "speed" not found
It seems that automatic argument initialisation doesn't work, as the only effectively valid call seems to be
with( data, aov.SS1( y=Obs, indep=speed, fSnr=Subject ) )
whereas
with( data, speed )
prints what one would expect (i.e. data$speed).
How come? From ?with, one learns that "... assignments within 'expr' take place in the constructed
environment and not in the user's workspace."
Which to me reads that a with statement as above is equivalent to
attach(data) ; aov.SS1(y=Obs) ; detach(data)
Or is that just wishful thinking??
RenE
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html