[R] "Object is not a matrix" Error
Joe King
jp at joepking.com
Mon Dec 21 00:32:34 CET 2009
When you imported did you not import the headers?
Joe King
206-913-2912
jp at joepking.com
"Never throughout history has a man who lived a life of ease left a name
worth remembering." --Theodore Roosevelt
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of jim holtman
Sent: Sunday, December 20, 2009 3:11 PM
To: John Paul Telthorst
Cc: r-help at r-project.org
Subject: Re: [R] "Object is not a matrix" Error
Where is the object 'write'? SHouldn't you be using:
lm(visits ~ (day.f))
On Sun, Dec 20, 2009 at 5:59 PM, John Paul Telthorst
<jptelthorst at gmail.com>wrote:
> I'm trying to follow this guide here:
> http://www.ats.ucla.edu/stat/r/modules/dummy_vars.htm
>
> In which I'm creating categorical variables using the factor function.
>
> I am able to go through the example listed above and have everything work,
> however, when I try to input my own numbers, I get an error. I input the
> following:
>
>
> > hits = read.csv(file.choose())
>
> > attach(hits)
>
> > day.f <- factor(day)
>
> > lm(write ~ (day.f))
>
> lm(write ~ (day.f))
>
> Error in model.frame.default(formula = write ~ (day.f), drop.unused.levels
> =
> > TRUE) :
> > object is not a matrix
> >
>
> So I import "hits = read.csv(file.choose())" a .csv file, which has the
> columns "visits" and "day" where "visits" is the number of hits to a
> website, and "day" is a number 1-7, for example 1 corresponds to Sunday
and
> 7 corresponds to Saturday. I understand that the day variable needs to be
> a
> categorical variable, and I'm trying to use the factor function to do
this.
> I would like to be able to run a regression that will correlate the day
> with the number of hits.
>
> Any help would be much appreciated.
>
> [[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<http://www.r-project.org/posting
-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
[[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