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

Murray Jorgensen maj at stats.waikato.ac.nz
Tue Sep 9 00:15:55 CEST 2003


I have just noticed that quite a few columns of a data frame that I am 
working on are numeric factors. For summary() purposes I want them to be 
vectors. I tried, for example

 > indx <- c(1:18,21:37,40,41)
 > i <- 0
 > i <- i+1
 > summary(as.vector(sflows1[indx[i]]))
            Length Class  Mode
min.pkt.sz 3000   factor numeric

but this does not give the five-number summary that I want. I know that 
I can go back and modify read.table() to change the class of the 
columns, but I want to change the frame without re-reading it.

Murray

-- 
Dr Murray Jorgensen      http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj at waikato.ac.nz                                Fax 7 838 4155
Phone  +64 7 838 4773 wk    +64 7 849 6486 home    Mobile 021 1395 862




More information about the R-help mailing list