From: Peter Dalgaard BSA <p.dalgaard at biostat.ku.dk> Date: 26 Jan 1999 15:43:08 +0100 Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
Try sep="\t", if they are really separated by tabs (they were not in your email by the time it reached here). Actually, you don't need as.if=F, either, as the first column should be the row names:
read.table("test.dat", header=T, row.names=1, sep="\t")
Number Napier 324 Auckland 657 Wellington 879 Christchurch 904 works on your example (with tabs in the file). (S-PLUS behaves differently here, and guesses the first column should be the row names without being told).
So does read.table on Unix - I don't remember it doing anything else?
(On R? Your own example shows it does not!)
And with the original data (TAB separated and with a header for col.1 too), I got
read.table("~/tmp/testdata", header=T)
City Number 1 Napier 324 2 Auckland 657 3 Wellington 879 4 Christchurch 904
class(read.table("~/tmp/testdata", header=T))
[1] "data.frame" I.e. no problem. ???
On Splus 3.4:
read.table("test.dat", header=T)
Number
Napier 324
Auckland 657
Wellington 879
Christchurch 904
which is not the same as R 0.63.2:
read.table("test.dat", header=T)
City Number 1 Napier 324 2 Auckland 657 3 Wellington 879 4 Christchurch 904 is it? That was my point: read.table in R and S-PLUS are subtly different.
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._