Skip to content

Newbie query - reading data into R

3 messages · Brian Ripley, Peter Dalgaard, Andy Elvey

#
(On R? Your own example shows it does not!)
On Splus 3.4:
Number 
      Napier    324
    Auckland    657
  Wellington    879
Christchurch    904

which is not the same as R 0.63.2:
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.
#
Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
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!):
..
..
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:)
City Number 
1       Napier    324
2     Auckland    657
3   Wellington    879
4   Wellington    879
5 Christchurch    904
#
Yes - good news here. I think I must have put an extra "tab" or some
such 
 thing in my text file. I re-edited it (carefully putting in only one
tab 
 after the first column). I then entered the command as follows -
City         Number
1 Napier       2341  
2 Hastings     3425  
3 Otara        7694  
4 Wellington    458  
5 Christchurch 2015  
6 Dunedin      3021  
7 Nelson        879
[1] "data.frame"
[1] "list" 

 Success!  

 ( I think I may have also been thrown by using the mode() function
(which shows "list")
 rather than the class() function which shows data-frame.  )

  Very many thanks to all who have helped me here.  Good to be part of a
community 
 using such a wonderful package ....  :-)
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._