[R] factor level

Bert Gunter gunter.berton at gene.com
Fri May 1 22:31:16 CEST 2009


If you read it in properly it _would_ be numeric. So there is either a stray
nonnumeric entry somewhere (comma, quote, ..?) -- check your input carefully
-- or you have not read it in properly. The latter appears to be the case:
what's that "newXaxis" level in the printout about? You need to fix this.


Bert Gunter
Nonclinical Biostatistics
467-7374

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of phoebe kong
Sent: Friday, May 01, 2009 1:16 PM
To: r-help
Subject: [R] factor level

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 at 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.




More information about the R-help mailing list