Split dataset by grouping variable to create multiple bar plots at once

I have a large dataset that looks like this:

time, precip, grp

2005-09-30 11:45:00,1.1,1

2005-09-30 23:45:00,1.5,1

2005-10-01 23:45:00,0.2,2

2005-10-02 11:45:00,0.3,2

2005-10-02 23:45:00,1.7,2

2005-10-03 11:45:00,0.8,2

2005-10-04 23:45:00,1.4,4

I want to make separate data frames for each group (grp, there are a total of 65 groups in my full dataset) and produce a bar graph for each group.

So far, I've made a list:

X <- split(df, df$grp)


Y <- lapply(seq_along(X), function(x) as.data.frame(X[[x]])[, 1:2]) 

lapply(seq_along(Y), function(x) {assign(grp[x], Y[[x]], envir=.GlobalEnv)})

which produces this:



                 time precip

3 2005-10-01 11:45:00      0

8 2005-10-03 23:45:00      0

9 2005-10-04 11:45:00      0


               time   precip

1 2005-09-30 11:45:00 1.1

2 2005-09-30 23:45:00 1.5


Is there a way to now plot each of these so that I have a different bar graph for each group, with time on the x-axis and precip on the y-axis? Ideally, the bar graphs would all be on the same page or part of the same output.

Also, is there a way to export each of these as separate data frames?

Thank you in advance!


lattice is made for this sort of thing.

Using RoyalTS's data df:

barchart(time~precip|grp, data=df)

Need Your Help

Is there an easier way to manipulate checkboxes in coldfusion?

forms coldfusion checkbox cfform

Basically, I have stored information in a database field and I want to display it again through a form.

Unit test for Ping / PingReply - Mocking?

c# visual-studio unit-testing mstest rhino-mocks

I was hoping to find a way to unit test my pinging functionality or be able to Mock it with RhinoMocks

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.