[R] Stucked with as.numeric function

patsko at gmx.de patsko at gmx.de
Mon Mar 21 18:57:27 CET 2011


Hi list,

I have problems with the as.numeric function. I have imported probabilities from external data, but they are classified as factors as str() shows. Therefore my goal is to convert the colum from factor to numeric level with keeping the decimals.

I have googled the problem for a while now and kept to several  advices like http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f and history from the list but it is impossible for me to convert the data to numeric without rounding or ranking the values. 

E.g.:
Simply using as.numeric puts the values into ranked classes as explained in the manual, 
As.numeric(as.character(probas)) as well as as.numeric(levels(probas$forecast_probs))[as.integer(probas$forecast_probs)]
 return “NA” for every row.

Anyone any idea?

--



More information about the R-help mailing list