[S] Eliminating factors from data frames

Benjamin Clardy (benjamin@clardy.net)
Sat, 17 Oct 1998 02:56:19 -0500

Has anyone created an unfactor() procedure that will reconvert
all factors in a data frame back to character and numeric variables?
I know I() can be used to avoid conversion to factors when using
data.frame(), but this can lead to undesirable variable names and
it doesn't help when the factor is output from an S-Plus procedure.

Obviously, as.character() will convert variables back to character,
and then as.numeric() can convert back to numeric, but how do I
determine if the field was originally numeric or character?

Also, has S-Plus 5.0 finally put in a as.is=T or equivalent switch
in data.frame() so we can possibly avoid this entire mess altogether.
I would even prefer a global environment variable so that all factor
conversion could be avoided. I never use categorical variables and
the memory space saving is trivial compared to all of the errors that
factors create, such as:
Error in Ops.factor( ... ): "/" not meaningful for factors

Just say no to factors.

This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news