Hello everybody, I have following string type and try to convert it to float:> a<-"20020104.123456" > str(as.numeric(a))num 20020104> str(as.real(a))num 20020104> str(as.double(a))num 20020104 How can I get an float instead of an integer? How can I set the desired precision? Thanks in advance Lutz Thieme Lutz Thieme AMD Saxony Manfacturing GmbH Product Engineering phone: +49 351 277-4269 fax: +49 351 277-9-4269 email: lutz.thieme at amd.com -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
lutz.thieme at amd.com writes:> Hello everybody, > > I have following string type and try to convert it to float: > > > a<-"20020104.123456" > > str(as.numeric(a)) > num 20020104 > > str(as.real(a)) > num 20020104 > > str(as.double(a)) > num 20020104 > > How can I get an float instead of an integer? How can I set the desired precision?It *is* a float. The precision is in the printing:> a<-"20020104.123456" > as.numeric(a)[1] 20020104> as.numeric(a)-20020104[1] 0.123456 -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._