Re: [R] read.table() and scientific notation

From: Prof Brian Ripley <>
Date: Tue 10 Oct 2006 - 11:03:31 GMT

On FC5 Linux:

gannet% cat > foo.dat
a 1 2e-4
b 2 3e-8
gannet% R
> read.table("foo.dat")

   V1 V2 V3
1 a 1 2e-04
2 b 2 3e-08
> sapply(read.table("foo.dat"), class)

        V1 V2 V3
  "factor" "integer" "numeric"

so please tell us your environment and give a reproducible example. (This is using the OS function strtod, so it might be a deficiency in your OS's implementation of ISO C.)

On Tue, 10 Oct 2006, January Weiner wrote:

> Dear all,
> I am having troubles importing values written as scientific notation
> using read.table(). I'm sure this is a frequent problem, as many
> people in my lab have this problem as well, so I'm sure that I just
> have troubles googling for the right solution.
> The problem is, that, given a file like that:
> a 1 2e-4
> b 2 3e-8
> ...
> the third column gets imported as a factor, or a string if I set the
> parameter of read.table to TRUE for this column. However, I just
> want a simple numeric vector :-) I'm sure there is a simple trick for
> this. If you can point me to the right function, or manual, I think I
> should be able to find out the details myself.
> Thanks in advance,
> January

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Tue Oct 10 21:13:19 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 10 Oct 2006 - 11:30:12 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.