Does this do it? barplot(t(matrix(pivot$x,4)),beside=T)
Tom On Fri, May 27, 2011 at 6:08 PM, steven mosher <mosherste...@gmail.com> wrote: > > Hi, > > I'm really struggling with barplot > > I have a data.frame with 3 columns. The first column represents an > "incident" type > The second column represents a "month" > The third column represents a "time" > > Code for a sample data.frame > > incidents <- rep(c('a','b','d','e'), each =25) > months <- rep(c(1,2), each =10) > times <-rnorm(100) > > # make my sample data > > DF <- > data.frame(Incidents=as.factor(incidents),Months=as.factor(months),Time=times) > > # now calculate a mean for the "by" groups of incident type and month > > pivot <- > aggregate(DF$Time,by=list(Incidents=DF$Incidents,Months=DF$Month),FUN=mean,simplify=TRUE) > > What I want to create is a bar plot where I have groupings by incident type > ( a,b,d,e) and within each group > I have the months in order. > > So group 1 would be Type "a"; month 1,2; > group 2 would be Type "b"; month 1,2; > group 3 would be Type "d"; month 1,2; > group 4 would be Type "3"; month 1,2; > > I know barplot is probably the right function but I'm a bit lost on how to > specify groupings etc > > TIA > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. ______________________________________________ R-help@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.