It's helpful to provide reproducible code in your posting to R help.  The 
dput() function can be used to share some of your data.  For example, you 
might have used 
        dput(mydata[1:10, 1:10])

# here's some data I made up as an example ...
df <- structure(list(`2000` = c(44L, 31L, 55L, 83L, 39L, 12L, 21L, 
20L, 52L, 63L, 92L, 90L, 22L, 71L, 23L, 46L, 84L, 9L, 98L, 47L
), `2001` = c(88L, 11L, 61L, 86L, 6L, 78L, 97L, 70L, 10L, 72L, 
14L, 37L, 94L, 60L, 8L, 19L, 73L, 57L, 2L, 30L), `2002` = c(29L, 
87L, 56L, 17L, 4L, 95L, 3L, 77L, 53L, 24L, 79L, 48L, 59L, 42L, 
54L, 28L, 25L, 18L, 43L, 15L), `2003` = c(16L, 40L, 58L, 65L, 
13L, 38L, 76L, 41L, 1L, 66L, 32L, 45L, 5L, 51L, 33L, 82L, 68L, 
74L, 91L, 69L), `2004` = c(67L, 7L, 75L, 80L, 99L, 89L, 81L, 
93L, 62L, 85L, 64L, 35L, 100L, 34L, 50L, 49L, 27L, 96L, 36L, 
26L)), .Names = c("2000", "2001", "2002", "2003", "2004"), row.names = 
c("Site A", 
"Site B", "Site C", "Site D", "Site E", "Site F", "Site G", "Site H", 
"Site I", "Site J", "Site K", "Site L", "Site M", "Site N", "Site O", 
"Site P", "Site Q", "Site R", "Site S", "Site T"), class = "data.frame")

# transpose the data (switch columns and rows)
df.turned <- as.data.frame(t(df))

# site names
sites <- names(df.turned)

# years
year <- as.numeric(dimnames(df.turned)[[1]])

# a separate plot for each site
for(i in seq(sites)) {
        plot(year, df.turned[, i], type="b", xlab="Year", ylab="My data", 
main=sites[i])
        }

Jean



megalops <megalop...@hotmail.com> wrote on 10/04/2012 03:01:17 PM:
> 
> 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. 

        [[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.

Reply via email to