[R] fitting a model for enumerated datatypes

Saket Joshi joshi at engr.orst.edu
Mon May 27 10:15:10 CEST 2002


I have used the scan() function to read data from a file as follows:

x <- scan("myfile", as.list(c(rep("", times = 9), class="", rep("", times
= 3))), comment.char="")

This reads in all the 13 fields. These 13 fields are enumerated or user
datatypes. I guess they are called factors in this context although I dont
know what exactly they are or are for. Now I tried to use the lm()
to fit a linear model as follows:

y <- lm(x$class ~ ., x)

But this is the error message I am getting:

Error in eval(expr, envir, enclos) : Object
"c..1....1....1....1....1....2....2....2....2....3....3....3..." not found

I looked at the lm() function code but could not find any eval() function
it. My guess is that the problem occurs because none of the variables
(either response or otherwise) are numeric, they are all user defined. Can
someone help by telling me how to fit a linear model to these
"non-numeric" fields or otherwise explain what the problem could be.

Thanks in advance.

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list