[R] basic question about lm summaries

Prof Brian D Ripley ripley at stats.ox.ac.uk
Fri Apr 23 09:00:45 CEST 1999


On Thu, 22 Apr 1999, andy bernat wrote:

> I'm very new to R and I'm having trouble doing something that should be
> very simple (so I'm probably missing something quite obvious).  When I
> run
> > lm(data$CRIME~data$INCOME+data$HOUSING)
> I get the correct coefficients.  However, when I try to get anything
> else out of this I get a message about a missing argument, e.g.:
> > summary.lm(lm.d1<-lm(data$CRIME~data$INCOME+data$HOUSING))
> Error: Argument "n" is missing, with no default
> None of the documentation mentions this argument "n", though I notice

You need to find out where that error message is coming from, by 
traceback(). The documentation for the function giving the error
probably mentions n.

I won't try to solve the problem (you need to send us an example to
reproduce), but I will try to help make using R easier.

-- use  lm(CRIME ~ INCOME + HOUSING, data=data). That is easier to read
   (it would be even easier without the capitals) and ensures that the
   variables are searched for in `data', which I hope is a data frame (but
   lists work too, I believe).

-- Don't ever call methods unless you mean to do something very unusual. Do
   summary(lm(CRIME ~ INCOME + HOUSING, data=data))

-- Unless you really need them, avoid assignments as arguments. They are
   hard to read and easy to miss when skimming code. In other words, use

   lm.d1 <- lm(data$CRIME~data$INCOME+data$HOUSING)
   summary(lm.d1)

-- Try the opposite convention, d1.lm. Names with a system name . something 
   are normally either methods or helper functions.  And surely it is the
   data that is important here, not lm.

-- Avoid names like `data'.  One guess as to the root of your problem is
   that another object named `data' (other than the one you meant) is 
   being found. Now, some analysis suggests that is unlikely, but if the 
   data frame had been called `UScrime' I would have had no analysis to do.

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list