Re: [R] about data structure

2016-11-07 Thread Jeff Newmiller
You have non-numeric data somewhere in that column, and factor is already a numeric type (Read about factors in the Introduction to R document that comes with R). Try DF$prec_new = as.numeric(as.character (DF$precip) and then look at DF$precip[ is.na( DF$precip_new ) ] to see which values

Re: [R] about data structure

2016-11-07 Thread Rui Barradas
Hello, Try as.numeric(as.character(DF$precip)) Hope this helps, Rui Barradas Em 07-11-2016 20:24, lily li escreveu: Hi R users, I'm wondering why the values changed when I try to transform factors into numerics. For example, for a data frame DF, there is one column called precipitation,

[R] about data structure

2016-11-07 Thread lily li
Hi R users, I'm wondering why the values changed when I try to transform factors into numerics. For example, for a data frame DF, there is one column called precipitation, which is usually lower than 100mm. But this column is factor when I read in the data. When transform to numeric values, some