I need to make about 30 figures and I am trying to create a program in R that will make my life a lot easier. First I will tell you how my data is setup. I have 30 sites and then data for each year at the site. I have 10 years of data for each site. Below is a small chunk of my data to show the format. 2000 2001 2002 2003 2004 Site A 50 75 25 55 60 Site B 58 22 68 77 30 I am trying to write a program in R that will create figures showing the annual data for each individual site. As opposed to making 30 individual graphs in Excel. Any help would be greatly appreciated. -- View this message in context: http://r.789695.n4.nabble.com/help-with-making-figures-tp4645074.html Sent from the R help mailing list archive at Nabble.com.
help with making figures
5 messages · Bert Gunter, Jean V Adams, megalops +1 more
First convert your data from short fat to long thin format: Column headings for the transformed data frame are: Year Site Result This can be done in a variety of ways, but check out the reshape2 package or the reshape function ins the stats package. Once you have the data in this form, , say in the data frame, mydat, you can plot the series by sites in a trellised layout. Either the lattice or ggplot2 package can do this easily. e.g. in lattice it is: xyplot(Result ~Year|Site, data = mydat, type = "b") You can adjust the layout etc. to your taste. There's lots more you can do, depending on what is important to you, but that should get you started. Cheers, Bert
On Thu, Oct 4, 2012 at 1:01 PM, megalops <megalops31 at hotmail.com> wrote:
I need to make about 30 figures and I am trying to create a program in R that will make my life a lot easier. First I will tell you how my data is setup. I have 30 sites and then data for each year at the site. I have 10 years of data for each site. Below is a small chunk of my data to show the format. 2000 2001 2002 2003 2004 Site A 50 75 25 55 60 Site B 58 22 68 77 30 I am trying to write a program in R that will create figures showing the annual data for each individual site. As opposed to making 30 individual graphs in Excel. Any help would be greatly appreciated. -- View this message in context: http://r.789695.n4.nabble.com/help-with-making-figures-tp4645074.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.
Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121005/85c44258/attachment.pl>
Bert, Can you help me understand your suggestion? I don't understand how I can include all 30 sites under the label called "site" in the xypot code example you provided. -- View this message in context: http://r.789695.n4.nabble.com/help-with-making-figures-tp4645074p4645216.html Sent from the R help mailing list archive at Nabble.com.
On 05.10.2012 21:59, megalops wrote:
Bert, Can you help me understand your suggestion?
Megalops31, which suggestion? You failed to quote former messages! I don't understand how I can
include all 30 sites under the label called "site" in the xypot
What is an xypot example? Please read the posting guide for this *mailing list*. Uwe Ligges
code example you provided. -- View this message in context: http://r.789695.n4.nabble.com/help-with-making-figures-tp4645074p4645216.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.