[R] read.table and factor
Bill Simpson
wsi at gcal.ac.uk
Mon Feb 21 12:16:05 CET 2000
> as.numeric(as.character(foo)), or if you really want to save space and
> have lots of repeated values
>
> as.numeric(levels(foo))[as.numeric(foo)]
>
> > How can I either tell read.table to leave the first two cols as numeric
> > (not factors) or convert them from factors into the proper numeric values?
I found the source of the problem--it was not read.table!
After reading in the data frame I do:
d<-aggregate(d[,-(1:2)], by=list(std=d$std, cf=d$cf), sum)
*This* makes std and cf into factors.
Anyway I have a good solution: as.numeric(as.character(foo))
[It might be better to find a way to collapse the data without using
aggregate().]
Thanks very much for the help Brian.
Bill
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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