Hello,
I have been struggling with this problem for a while now and anyone who can help me out I would greatly appreciate it.
First off, I am working with time series data in a single data frame containing multiple time series. Too many to output individually into graphs. I have tried passing qplot() through ddply() however r tells me it qplot is not a function and therefore it will not work.
the structure of my data is like this...
goodlocs <-
Loc Year dir
Artesia 1983 1490
Artesia 1984 1575
Artesia 1986 1567
Artesia 1987 1630
Artesia 1990 1680
Bogota 1983 1525
Bogota 1984 1610
Bogota 1985 1602
Bogota 1986 1665
Bogota 1990 1715
Carlsbad 1983 1560
Carlsbad 1985 1645
Carlsbad 1986 1637
Carlsbad 1987 1700
Carlsbad 1990 1750
Carlsbad 1992 1595
Datil 1987 1680
Datil 1990 1672
Datil 1991 1735
Datil 1992 1785
I have about 250 Locations(Locs) and would like to be able to go over each stations data on a graph like the following one so I can inspect all of my data visually.
Artesia <- goodlocs[goodlocs$Loc == "Artesia",]
qplot(YEAR, dir, data = Artesia, geom = c("point", "line"), xlab = "Year",
ylab = "DIR", main = "Artesia DIR Over Record Period") +
geom_smooth(method=lm)
I understand that Par() is supposed to help do this but I can not figure it out for the life of me. Any help is greatly appreciated.
Thanks,
-Zia
edit -
as Arun pointed out, I am trying to save a .pdf of 250 different graphs of my goodlocs df split by "Loc", with point and line geometry for data review....
I also tried passing a ddply of my df through qplot as the data but it did not work either, I was not really expecting it to but i had to try.
How about this?
The idea: First split the data by
Loc
and create the plot for each subset. The splitting part is done usingplyr
functiondlply
that basically takes adata.frame
as input and provides alist
as output. The plot element is stored in each element of the list corresponding to the subset. Then, we usegridExtra
package'smarrangeGrob
function to arrange multiple plots (which also has the very usefulnrow
andncol
arguments to set the argument). Then, you can save it usingggsave
fromggplot2
.I'll leave you to any additional tweaks you may require.