[R] converting string to float
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Mon Feb 4 14:15:53 CET 2002
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list