[R] lm function - strange error

John Kane jrkrideau at inbox.com
Fri Nov 9 18:23:55 CET 2012


Can you provide a reference or link to the document?  I think that you have a misprint or a typo in it.

the na.omit is a reference to missing data that is accounted for in the vector, which would appear as NA in the data.

For example this works just fine for me
conc = c(0, 10, 20, 30, 40, 50)
signal = c (4, 22, 44, 60, 82, NA)
lm( signal ~ conc)

as does this

conc = c(0, 10, 20, 30, 40, 50)
signal = c (NA, 4, 22, 44, 60, 82)
lm( signal ~ conc)

but they give very different results.

I don't think R has changed ----someone just make typing mistake.





John Kane
Kingston ON Canada


> -----Original Message-----
> From: tesarants at gmail.com
> Sent: Fri, 9 Nov 2012 08:37:13 -0800 (PST)
> To: r-help at r-project.org
> Subject: [R] lm function - strange error
> 
> I am following a document teaching how to use regression and right at the
> onset I get an R error.  I understand that variables "conc" and "signal"
> should have the same length but  I am using the what R manual suggests to
> drop the error and it is not cooperating.  What gives?   The manual says
> that the default is na.ombit by the way, not that it's addition does
> anything
> 
> How do I make it omit the extra items?  I want to follow this document
> but
> it seems that R has changed since that one was written
> 
> Here is the code
> 
> conc = c(0 10 20 30 40 50)
> signal = c (4, 22, 44, 60, 82)
> lm( signal ~ conc)
> 
> #Error in model.frame.default(formula = signal ~ conc, drop.unused.levels
> =
> TRUE) :
> #variable lengths differ (found for 'conc')
> 
> 
> lm (conc~signal, na.action=na.omit)
> #Error in model.frame.default(formula = conc ~ signal, na.action =
> na.omit,
> :
> #variable lengths differ (found for 'signal')
> 
> 
> lm (conc~signal, na.action=na.exclude)
> #Error in model.frame.default(formula = conc ~ signal, na.action =
> na.exclude,  :
> #variable lengths differ (found for 'signal')
> 
> 
> 
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/lm-function-strange-error-tp4649065.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at 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.

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!




More information about the R-help mailing list