[R] question on function argument

Edwin Leuven e.leuven at uva.nl
Mon Oct 11 14:33:19 CEST 2004


> (1) Insufficient information in problem report (what is "myframe"?)
>
> Assuming that myframe is a data.frame containing a variable called
> "x1":

correct

> (2) Believing that function calls are macros and

you must be right. from the examples in the r-intro i was under the 
impression that R substitutes the value of the arguments in the 
expression in the function body.

but apparently this is not happening (although i only noticed now).

is there a document which explains more in detail what does happen 
when functions are evaluated? because...

> (3) Not noticing that subset() has nonstandard argument handling

...otherwise there might be unexpected behavior...


> I think that what you thought you were doing is more like
>
> myhist<-function(yvar) eval.parent(substitute({
>   y<-subset(myframe,yvar>1 & yvar<=150000,select=yvar)
>   attach(y)
>   hist(yvar)
> }))

this is indeed the one

> In either case, you'd probably want a detach() in there as well.

yes, thanks for your help!

regards, edwin




More information about the R-help mailing list