[R] help with making figures
gunter.berton at gene.com
Thu Oct 4 23:15:18 CEST 2012
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.
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
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Genentech Nonclinical Biostatistics
Internal Contact Info:
More information about the R-help