[R] beginner data.frame question

David Winsemius dwinsemius at comcast.net
Wed Dec 24 00:44:57 CET 2008


 > class(co2)
[1] "ts"
 > is.data.frame(co2)
[1] FALSE

If you try these functions on your test.data I am guessing that the  
results will differ from above.

-- 
David Winsemius
On Dec 23, 2008, at 6:29 PM, Kirk Wythers wrote:

> 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 command
>
> > 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.
>
> ______________________________________________
> R-help at r-project.org 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.



More information about the R-help mailing list