If you are reading a data frame (with read.table) you will get a factor
corresponding to the columns with that form of number in them.
You can use the translate() function from the Hmisc library:
library(Hmisc)
tab <- read.table("dform.txt")
tab$Dnum <- as.numeric(translate(as.character(tab$Dnum, "D", "e")))
will do the trick. On the other hand if you are just reading numbers with,
say, scan() you can omit the as.character():
Dnum <- as.numeric(translate(scan("Dform.txt", what=""), "D", "e"))
Bill Venables.
-----Original Message-----
From: Micha Levi [mailto:micha@c255.ucsf.edu]
Sent: Wednesday, July 23, 2003 12:50 PM
To: s-news@wubios.wustl.edu
Subject: [S] reading a table to Splus
Dear All,
I am attempting to read a table with the following number notation to
Splus with no success:
3.5348439948189D-02 8.0503419433667D-02
In order to read the numbers in this format i am replacing the D with
E (using a text editor).
Is there a way to make Splus reads number in that format?
Alternatively, is there a way to automate replacing the D with an E?
Thanks in advance,
Micha
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
|