[R] beginner data.frame question

Kirk Wythers kwythers at umn.edu
Wed Dec 24 00:29:56 CET 2008

I need some help understanding how on of the example data sets is  
formatted in the basic R installation. If I load the Mona Loa CO2  
data, with the command:

 > data(co2)

I can view the data with:

 > co2

And the data are in the form of 11 rows labeled as years (1994-2004)  
and 12 columns labeled (Jan - Dec). This structure appears to be a  
dataframe, however, if I type the command

 > plot(co2)

I get a time series with CO2 on the x axis and time on the y. Also,

 > summary(co2) gives a single Min, Median, Max.

The reason for my confusion is that I created another "similar  
looking" data set with read.table. In that case, the data looks to be  
in same format (rows as years, and columns as months). However, the  

 > summary(test.data)

gives a summary for each month. Completely different behavior.

If use the data.frame command:

 > data.frame(co2)

I get a single column of CO2 data, while the data.frame command on my  
test.data data, keeps it's year-row, column-month format.

Can anyone help me understand the differences in how these data sets  
are formatted?

Thanks in advance.

More information about the R-help mailing list