[R] How to coerce data frame elements into factors?

Andrew Perrin aperrin at socrates.berkeley.edu
Thu Mar 1 20:22:52 CET 2001


Greetings -

In trying to do a multiple correspondence analysis, I need to coerce a
data frame such that each of its columns will be a factor.  Can someone
offer advice on how to make this happen?  I've tried this:

> logic.resources.f.df<-apply(logics.resources.df, 2, factor)

but:

> is.factor(logic.resources.f.df$interests)
[1] FALSE


I've also tried individually,

> foo<-data.frame(c(factor(mediate), factor(morality)))

but still,

> is.factor(foo$mediate)
[1] FALSE


Thanks for any assistance.

----------------------------------------------------------------------
Andrew J Perrin - Ph.D. Candidate, UC Berkeley, Dept. of Sociology  
Chapel Hill, North Carolina, USA - http://demog.berkeley.edu/~aperrin
        aperrin at socrates.berkeley.edu - aperrin at igc.apc.org


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