[S] data frame manipulation

Paul Schwarz (Paul.Schwarz@cornell.edu)
Wed, 08 Apr 1998 11:13:44 -0400

I'm developing my data manipulation skills in S-PLUS, and I've encountered
the following problem. Using the "barley" data frame as an example, I'd
like to create a new data frame containing the year by site mean yields
where years are the rows and sites are the columns.

I know how to calculate the summary data using the aggregate function:

> aggregate( barley[,1], list(year,site), mean )

This creates a data frame that looks like the following:

Group.1 Group.2 x
1 1932 Grand Rapids 20.81000
2 1931 Grand Rapids 29.05334
3 1932 Duluth 25.70000
4 1931 Duluth 30.29333
5 1932 University Farm 29.50667
6 1931 University Farm 35.82667

What I want end up with, though, is something that looks like this:

Year 'Grand Rapids' 'Duluth' 'University Farm' ...
1931 29.05334 30.29333 35.82667 ...
1932 20.81000 25.70000 29.50667 ...

I'm not sure how to create this last data frame. Any suggestions?

Thanks again!


P.S. Until I am re-subscribed to s-news, would you kindly cc: any
responses directly to me please?

This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news