Re: [R] Optional data argument for a function

2008-02-29 Thread Henrique Dallazuanna
One option is: dosomething <- function(x, data, env=parent.frame()) { if(!missing(data)) x <- data[,deparse(substitute(x))] temp <- x^2 + 5 return(temp) } On 29/02/2008, Viechtbauer Wolfgang (STAT) <[EMAIL PROTECTED]> wrote: > Dear All, > > I am working on a function that ha

[R] Optional data argument for a function

2008-02-29 Thread Viechtbauer Wolfgang (STAT)
Dear All, I am working on a function that has an optional data argument, just like lm(). If the user sets the data argument equal to some dataframe, then the function should look inside the dataframe for the variables given to other arguments, otherwise the variables should be accessible from w