[R] read.table, input methods

Thomas Lumley thomas at biostat.washington.edu
Mon Jan 3 18:16:21 CET 2000


On Mon, 3 Jan 2000, John D. Barnett wrote:

> Hi-
> 
> I'm trying to read data into R that was exported from Excel, as
> tab-delimited text.  There are some empty cells in the spreadsheet,
> which I'd like to treat as missing values.
> 
> I'd like to specify to read.table to use a *single* tab character as the
> record separator, but I can't seem to do this.  First of all, how can I
> get a tab character in R?  Second, is it possible to force read.table
> not to skip multiple separators?

You can specify tabs in C format, with \t
eg
R> cat("a\tb\n")
a       b

read.table will generally skip multiple separators

I tried the following file (where the tabs are actually tabs)

1               2
3       4       5

R> read.table("/tmp/tmp",sep="\t")
  V1 V2 V3
1  1 NA  2
2  3  4  5



You might also be able to import data directly from Excel into R for
Windows using the COM server, but I haven't tried this.


	-thomas

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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