Hi,
     I am writing a function and need to pass a function expression as an 
argument,   for instance, 
            myfun <-  function( express) {
                   x<- c(1,2,3)
                  y<-express
         }

    if I call the above function by myfun( x*2 ), I get  2  as the result,  
instead of  2,4,6 ,  could someone help me to 
fix this problem ? 
    Furthermore,  is that possible to operate this expression on different 
variables?  for example, in myfun(), I 
might want to get  u*2,  z*2,  etc. without having to say x<-u, x<-z to match 
the expression.

Thanks a lot for your help.

best

______________________________________________
R-help@stat.math.ethz.ch 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