[R] about data structure

Rui Barradas ruipbarradas at sapo.pt
Mon Nov 7 21:30:53 CET 2016


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,
> which is usually lower than 100mm. But this column is factor when I read in
> the data. When transform to numeric values, some rows can be higher than
> 1000mm. What is the problem? Thanks.
>
> DF$prec_new = as.numeric(DF$precip)
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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