[R] read.table with double precision
Sarah Goslee
sarah.goslee at gmail.com
Thu Nov 17 18:33:26 CET 2011
Hi,
On Thu, Nov 17, 2011 at 11:49 AM, Alaios <alaios at yahoo.com> wrote:
> Dear all I have a txt file with the following contents
> 1 50.7906430000000 6.06349800000000
> 2 50.7907380000000 6.06347100000000
> 3 50.7910810000000 6.06338000000000
> 4 50.7911890000000 6.06355200000000
>
>
> I am usind read.table('myfile.txt',sep=" ")
>
> which unfortunately returns only integers and not doubles that are required to store the
>
> 50.7906430000000
Using that exact file you included? If so, then I suspect you are
confusing display and storage, though even then my default session
doesn't show integers.
How do you know that it is returning only integers? What is
options()$digits set to?
> myfile
V1 V2 V3
1 1 50.790643 6.063498
2 2 50.790738 6.063471
3 3 50.791081 6.063380
4 4 50.791189 6.063552
> sprintf("%2.10f", myfile[1,2])
[1] "50.7906430000"
> What can I do to force it to store things into doubles?
What is str(myfile) ?
Sarah
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list