[R] lm without a formula?

Prof Brian Ripley
2004-05-12T21:05:29Z

x <- data.frame( x1=rnorm(10), x2=rnorm(10) )
lm(y ~., data=x)

seems to be what you want.

BTW, R is not C/Perl/... and ; is a separator, not a terminator.

On Wed, 12 May 2004, ivo welch wrote:

>
> hi:  I have a y vector and an x data frame.  is it possible to use the
> standard linear regression (lm, summary.lm) without having to construct
> a formula, i.e., all x variables should be used.
>
>     x <- data.frame( rnorm(10), rnorm(10) );  # <-- well, this would
> really be read from a file
>     y <- rnorm(10);  # ok, also read from the file.
>     lm (y ~ x);  # this is sort of what I want to do, but of course, it
> is not.

--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595