Hi, I have a dataset which includes monthly data for 17 years. I want to be able to see the monthly data behavior for the period of all 17 years. What my data looks like: http://r.789695.n4.nabble.com/file/n4162534/data.jpg I would like to represent the data in a graph such as the one below: http://r.789695.n4.nabble.com/file/n4162534/Untitled-2.jpg Any help would be appreciated. Thanks! -- View this message in context: http://r.789695.n4.nabble.com/Plotting-Time-Series-Data-by-Month-tp4162534p4162534.html Sent from the R help mailing list archive at Nabble.com.
Your data set is not reproducible from an image (use dput() on your next post to give us a taste of your data) but I'll hazard it's a ts class object. If so, try this: X <- ts( sample(500, 204), frequency = 12, start = 1995) plot( rep(1:12, 17), X, col = rep(1:17, each = 12), xaxt = "n", xlab "Months", pch = 20) axis(1, at = 1:12, label = month.abb, padj = 0) legend("bottom", pch = 20, col = 1:17, label = 1995:2011, horiz = TRUE) as a start. You can add the grid lines with (among others) the abline function's h argument. Michael On Mon, Dec 5, 2011 at 5:58 PM, crazedruff <smoochie3002 at gmail.com> wrote:> Hi, > > I have a dataset which includes monthly data for 17 years. I want to be able > to see the monthly data behavior for the period of all 17 years. > > What my data looks like: > > http://r.789695.n4.nabble.com/file/n4162534/data.jpg > > I would like to represent the data in a graph such as the one below: > > http://r.789695.n4.nabble.com/file/n4162534/Untitled-2.jpg > > Any help would be appreciated. > > Thanks! > > -- > View this message in context: http://r.789695.n4.nabble.com/Plotting-Time-Series-Data-by-Month-tp4162534p4162534.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
Sorry about that, new to posting here! Your code was extremely helpful, and tweaking it a bit gave me the output I was looking for: plot( rep(1:12, 17), pox, col = rep(1:17, each = 12), xaxt = "n", ylab="Reported Cases",xlab "Months", pch = 20, main="Monthly Trends of Chickenpox") axis(1, at = 1:12, labels = month.abb, padj = 0) legend(8, 28000,c("1993", "1994","1995","1996","1997","1998","1999","2000", "2001","2002","2003","2004","2005","2006","2007","2008","2009"), inset=.05, title="Years", c(1993:2009), pch=20, horiz=FALSE, cex=.7) Apparently there aren't enough colors for each year to have it's own individual color, but I think I can live with that. Thanks again! -- View this message in context: http://r.789695.n4.nabble.com/Plotting-Time-Series-Data-by-Month-tp4162534p4170305.html Sent from the R help mailing list archive at Nabble.com.