[R] Character coerced to factor and I cannot get it back

Tyler Smith tyler.smith at mail.mcgill.ca
Thu Apr 19 21:03:24 CEST 2007


I really need to sit down with the manual and sort factors and classes
properly. In your case, I think the problem has something to do with
the way a list behaves?  I'm not sure, but if you convert your list to
a dataframe it seems to work ok:

> dd3 <- as.data.frame(dd1)
> typeof(dd3$st)
[1] "integer"
> class(dd3$st)
[1] "factor"
> dd3$st <- as.character(dd3$st)
> typeof(dd3$st)
[1] "character"
> class(dd3$st)
[1] "character"

HTH,

Tyler



More information about the R-help mailing list