Re: [R] Passing in arguments into function

2011-01-24 Thread Ivan Calandra
Hi, If you have the formula stored in a string, you could also use as.formula in your call to lm, like this: form - x ~ y + z lm(as.formula(form)) HTH, Ivan Le 1/23/2011 21:38, Joshua Wiley a écrit : Hi Paul, You need to pass the formula object, not a string. If you have a function that

Re: [R] Passing in arguments into function

2011-01-24 Thread Henrique Dallazuanna
Isn't necessary a formula, but a class that could be coerced to that class: x - rnorm(100) y - rnorm(100) z - rnorm(100) lm(x ~ y + z) On Sun, Jan 23, 2011 at 2:46 PM, Paul Evans p.evan...@yahoo.com wrote: Hi, I had a function that looked like: diff - lm(x ~ y + z) How can I pass the

[R] Passing in arguments into function

2011-01-23 Thread Paul Evans
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

Re: [R] Passing in arguments into function

2011-01-23 Thread Joshua Wiley
Hi Paul, You need to pass the formula object, not a string. If you have a function that is passing one of its arguments down to lm(), just pass the argument directly, no need to do anything special. Here are some examples using a built in dataset: ## wrapper function foo - function(fooform,