[R] lm function - strange error

R. Michael Weylandt michael.weylandt at gmail.com
Fri Nov 9 17:59:08 CET 2012


On Fri, Nov 9, 2012 at 4:37 PM, tesssa <tesaRants at gmail.com> wrote:
> 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)

Off the cuff, it seems you're missing commas here.

RMW


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




More information about the R-help mailing list