[R] question on function argument

Edwin Leuven e.leuven at uva.nl
Mon Oct 11 13:20:28 CEST 2004


dear all,

i've looked at the r-intro (chapter 10, writing your own functions) 
and searched the r-help archives but am still stuck at the following.

i have a simple function, something like:

myhist<-function(yvar) {
  y<-subset(myframe,yvar>1 & yvar<=150000,select=yvar)
  attach(y)
  hist(yvar)
}


calling it as follows:

myhist(x1)

gives the following error:

Error in attach(y) : attempt to set an attribute on NULL



what am i doing wrong here?

thanks in advance, edwin




More information about the R-help mailing list