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
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
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
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,
4 matches
Mail list logo