Dear phoebe, See http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f
HTH, Jorge On Fri, May 1, 2009 at 4:15 PM, phoebe kong <sityeek...@gmail.com> wrote: > Hi All, > > I have problem about the factor features. > > I read in a .cvs file, a column which is supposed to be numeric, but it > becomes factor level data after reading in. > > mydata[,"newXaxis"] > [1] 0 0.430010601 11.23198508 25.00940297 37.75338045 > 45.98289639 > [7] 48.92328133 52.51142822 61.12359751 63.85832121 70.98927949 > 77.16550181 > [13] 97.73545713 113.6588007 118.6588007 129.9635717 151.8944844 > 178.7997437 > [19] 206.45806 248.5916724 309.2463405 373.436891 441.0136089 > 508.6003268 > [25] 586.8717683 670.5198381 760.8728108 854.0728565 948.6242311 > 1048.159042 > [31] 1150.177895 1257.016622 1262.016622 1273.775731 1295.941555 > 1331.142905 > [37] 1368.605796 1419.096727 1478.299769 1557.275945 1636.262122 > 1641.262122 > [43] 1642.586431 > > 44 Levels: 0 0.430010601 10030.11259 10096.32795 10167.4591 ... newXaxis > > I tried to convert this column to numeric using command: > > mydata[,"newXaxis"]<-as.numeric(mydata[,"newXaxis"]) > > However, it turned out a batch of integer numbers. > > > as.numeric(mydata[,"newXaxis"]) > [1] 1 2 31 202 230 245 250 256 271 276 292 307 337 33 46 82 124 > 186 > [19] 191 201 213 228 240 253 266 280 305 317 332 15 39 64 65 71 80 > 87 > [37] 92 97 112 > > Does anyone know how to remove the factor and remain the actual numeric > data? > > Thanks a lot! > > Phoebe > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.