[R] Regression

Erik Iverson eriki at ccbr.umn.edu
Thu Apr 1 21:05:52 CEST 2010


Bruce,

You don't tell us what class of data your y is.  Assuming y is defined 
in your enviroment, what does

class(y)

and

str(y)


tell you?  You'll most likely have to fine-tune your data reading 
process, or do some post-processing to make sure the y object (and x for 
that matter) are the classes you want.

And as always,
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

You can give us samples of your data with the dput function, see ?dput.

Bruce Kindseth wrote:
> I am trying to learn R, and am having problems with doing a simple linear
> regression.  I loaded data from a fixed width file, using wd=c(...), and
> read.fwf(...) and I can read in the file ok and it comes in as vectors in
> columns, which is what I expected.  The problem is when I try to do a linear
> regression, lm=(y~x), I get the following error message, "Error in
> model.frame.default(formula = y ~ x, drop.unused.levels = TRUE) : 
> 
>   invalid type (list) for variable 'y'
> 
>  
> 
> I tried various things, such as wd=numeric(c(..)), unlist(y) and putting x
> and y in a data frame and attaching it, but nothing helps.  I have searched
> through 3 online manuals, but can't seem to find an answer.  Maybe this is
> so simple that nobody felt the need to address it.  
> 
>  
> 
> Thanks for your help.
> 
>  
> 
> B.Kindseth
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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