Try using dot notation:

lm(y ~., x.d)


On 3/25/06, ivo welch <[EMAIL PROTECTED]> wrote:
> Dear R wizards:  This must have an obvious solution, but I am stumped.
>  I can run a linear regression giving a matrix as the independent set
> of variables, but if I give a data frame (which I would like to give,
> because it should tell the linear model the names of the variables), R
> does not like it.  An example is:
>
> N=20; y= rnorm(N);
> x.m <- (matrix( nrow=N, ncol=2 ));
> x.m[,1]=rnorm(N); x.m[,2]=rnorm(N);
>
> print(summary(lm(y ~ x.m)));  # works
>
> x.d <- as.data.frame(x.m);
> names(x.d) <- c("one.rv", "two.rv");  # I would like the summary to
> know my variable names!
>
> print(summary(lm(y ~ x.d)));  # fails
>
> [please indulge my semi-colons.]  how should this be done?  help, as
> always, appreciated.
>
> sincerely,
>
> /ivo welch
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to