I'm trying to create hundreds of plots (one plot for each site/program) for time series data (annual water quality averages over the years). I need to plot each site/program combination with each parameter (ANC, DOC, etc). Years run from 1990 to 2017. When a parameter isn't collected, it's stored as a 0, but I can change this to a null if needed. I'd like to do this as one code/script to save time.
I'm more familiar with ggplot2, but I'm open to other packages as well.
Here's an example of my data:
PROGRAM <fctr> SITE <fctr> YEAR <int> ANC <dbl> DOC <dbl> NO3 <dbl> SBC_ALL <dbl> SBC.0 <dbl> SO4 <dbl>
1 VTSSS VT64 1992 66.753 0 0.803 94.890 0 8.135
2 VTSSS VT64 1998 64.778 0 0.803 92.783 0 8.230
3 VTSSS VT43 1995 58.925 0 0.698 91.945 0 8.730
4 VTSSS VT43 1990 63.240 0 0.885 91.618 0 8.733
5 VTSSS VT43 1992 66.043 0 0.825 93.873 0 8.758
6 VTSSS VT43 2004 66.298 0 0.688 95.358 0 8.813
I've tried ggplot, but it only comes up with an empty graph. I'm thinking I need a graphing package where I can subset by PROGRAM and SITE.
I've tried:
ggplot(data = mydata, mapping = aes(x = "year", y = "anc", color = "site")) +
geom_line() +
theme_bw()
Expected Results: Want to have a plot for site: VT43 and parameter: ANC over time (1990 to 2017). VT43 and DOC. VT43 and NO3. Etc....
Actual Results:
Empty graph with year on the x axis, anc on the y axis, and no dots or lines for sites.