[R] Newbie query - reading data into R

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue Jan 26 16:51:25 CET 1999


Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:

> > >              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!)

Whooops. I assumed that the input file had had the "City" header
removed when I saw that display. I honestly didn't believe that S-plus
could be that silly (it scans the variables, grabs the first
nonnumeric one that has no duplicated values and uses it for
rownames!):


> On Splus 3.4:
> > read.table("test.dat", header=T)
>              Number 
>       Napier    324
..
> which is not the same as R 0.63.2:
> > read.table("test.dat", header=T)
>           City Number
> 1       Napier    324
..
> 
> is it?  That was my point: read.table in R and S-PLUS are subtly different.

Agreed. However, even after noticing the difference, I really don't
think that that bit of S-plus behaviour is worth cloning. 

(S-plus, after duplicating the Wellington line:)
> read.table('tmp/testdata',header=T)     
          City Number 
1       Napier    324
2     Auckland    657
3   Wellington    879
4   Wellington    879
5 Christchurch    904

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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