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

Reply via email to