[R] How do I coerce numeric factor columns of data frame to vector?

Michael A. Miller mmiller3 at iupui.edu
Tue Sep 9 17:01:58 CEST 2003

>>>>> "Thomas" == Thomas W Blackwell <tblackw at umich.edu> writes:

    > Michael - Because these columns are factors to begin with,
    > using as.numeric() alone will have unexpected results.  See
    > the section "Warning:" in help("factor").

Ah, thanks for pointing that out.  When I've used as.numeric on
factors, it is usually because I've explicitly made a numeric
variable a factor.  I can see where something that I think aught
to be numeric would be interpreted as a factor, say due to an
error in formatting an input file.  If I do something like this:

x <- some numeric array
f <- factor(x)
y <- as.numeric(x)

is there a possibility of y not equalling x?  If x really is
numeric that is.

Regards, Mike

Michael A. Miller                               mmiller3 at iupui.edu
  Imaging Sciences, Department of Radiology, IU School of Medicine

More information about the R-help mailing list