Hi Tim, I already answered this exact question from a different poster (by the name of Paul Evans, subject: "Passing in arguments into function"), that occurred within marvelous temporal proximity to your own, so I will just refer you to that (search the archives with name + subject).
Just as a note, diff() is a function, so it is probably best to give the variable you store the results of a call to lm() in a different name, even if it is trivially different: diff1 <- lm(x ~ y + z) It can help to prevent future confusion and headache. Cheers, Josh On Sun, Jan 23, 2011 at 8:44 AM, Tim Smith <tim_smith_...@yahoo.com> wrote: > Hi, > > I had a function that looked like: > > diff <- lm(x ~ y + z) > > How can I pass the argument to the 'lm' function on the fly? E.g., if I pass > it > in as a string (e.g. "x ~ y + z"), then the lm function treats it as a string > and not a proper argument. > > many thanks > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org 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. > -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ ______________________________________________ R-help@r-project.org 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.