This being R, there are likely other ways, but I use:

lm(as.formula(paste(nnn, "~ .")),data=X)


Sarah

On Sun, Oct 13, 2013 at 5:04 PM, David Epstein
<david.epst...@warwick.ac.uk> wrote:
> lm(height ~ ., data=X)
> works fine.
>
> However
> nnn <- "height" ;  lm(nnn ~ . ,data=X)
> fails
>
> How do I write such a formula, which depends on the value of a string 
> variable like nnn above?
>
> A typical application might be a program that takes a data frame containing 
> only numerical data, and figures out which of the columns can be best 
> predicted from all the other columns.
>
> Thanks
> David
>

-- 
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
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.

Reply via email to