Example data in a recent post was:
                       LandFill Ruminants
United States (USA) 7777.214280   5528.16
France               200.527083   1299.87
Australia            185.878368   2448.17
Russian Federation  1752.833400   2024.29
Argentina            283.987320   2567.02
Brazil              1048.422480   8839.61
Colombia             265.125000   1307.61
Mexico               981.023351   1814.89
Ethiopia               9.380204   1237.49
Sudan                 16.018494   1796.67
India                553.425328  12360.30
Pakistan              47.159393   2346.71
China                455.680191   8041.79

In trying to play with this posting, I saved the data as a .csv file where the 
first row had only two entries and read:
 , LandFill, Reminants  

I tried reading the data in with 
read.csv("ex.csv", header=TRUE) 

To my surprise this created a 3 column dataframe with the first column labeled 
as X.  X was a factor.  According to the help file:

"If there is a header and the first row contains one fewer field than the 
number of columns, the first column in the input is used for the row names. 
Otherwise if row.names is missing, the rows are numbered. "

I got the expected default behavior of having the unlabeled column become row 
labels when I tried,
read.csv("ex.csv", header=TRUE, row.names=1)

Is this unexpected behavior somehow related to how I designed a .csv file or is 
there something I'm misinterpreting in the documentation?

Thanks,
Rob Baer

> version
               _                           
platform       i386-pc-mingw32             
arch           i386                        
os             mingw32                     
system         i386, mingw32               
status                                     
major          2                           
minor          4.0                         
year           2006                        
month          10                          
day            03                          
svn rev        39566                       
language       R                           
version.string R version 2.4.0 (2006-10-03)


 

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to