[R] Re: prevent conversion to factors in aggregate?

Jeff D. Hamann jeff.hamann at forestinformatics.com
Sun Nov 16 19:46:50 CET 2003


Ah ha! That's perfect. It would have taken me forever to get that. And I'm
back in business....

Thanks,
Jeff.


----- Original Message ----- 
From: "Dieter Menne" <dieter.menne at menne-biomed.de>
To: <spencer.graves at pdf.com>; <jeff.hamann at forestinformatics.com>; "R-Help"
<r-help at hypatia.math.ethz.ch>
Sent: Sunday, November 16, 2003 10:23 AM
Subject: prevent conversion to factors in aggregate?


> Spencer Graves wrote
>
> >>I don't know how to prevent aggregate from making factors of everything,
> >>but the following shows how to cast them back into what you want:
> ....
> > DF.$bch <- as.character(DF.$b)
> > DF.$dn <- as.numeric(as.character(DF.$d))
> > sapply(DF., class)
> ...
>
> ----
> help(factor) suggests:
>
> "To "revert" a factor f to its original numeric values,
> as.numeric(levels(f))[f] is recommended and slightly more efficient than
> as.numeric(as.character(f)). "
>
> And in package Hmisc there is a function "summarize" that does not touch
> non-factors.
>
> Dieter Menne
>
>




More information about the R-help mailing list