Hi, (@FactOREO --this is somewhat related to my previous questions you helped with)
I have a large dataset with multiple parameters, and multiple sampling stations. I want to make plots of every parameter for every station. I can use facet_wrap to create plots for my selected stations. But, how do i repeat this for all parameters, other than typing in the name for each parameter?
Some of my script (the "filter(parm == "pH") %>% is the step I want to automate, and do this for all parms:
## Select stations with adequate data
df2 <- df %>%
filter(station %in% c("23917", "24734", "24764", "24805", "24833", "25020039"))
#> Error in df %>% filter(station %in% c("23917", "24734", "24764", "24805", : could not find function "%>%"
## Plot data
p1 <- df2 %>%
filter(parm == "pH") %>%
ggplot(aes(x = date, y = value)) +
geom_point() +
labs(y = "pH (SU)", x = "Year") +
scale_y_continuous(limits = c(4,10), breaks = c(4, 5, 6, 7, 8, 9, 10)) +
facet_wrap(~station)
#> Error in df2 %>% filter(parm == "pH") %>% ggplot(aes(x = date, y = value)): could not find function "%>%"
p1
#> Error in eval(expr, envir, enclos): object 'p1' not found
Created on 2022-12-02 by the reprex package (v2.0.1)
Some of the data:
station | date | time | parm | value | unit |
---|---|---|---|---|---|
51433 | 6/14/2017 | 1:55:00 PM | Fluorides | .91 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Hardness, Ca + Mg | 171 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Calcium | 38.1 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Total Suspended Solids (TSS) | 9 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Pheophytin-a | 4.5 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Antimony | .24 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Turbidity | 6 | NTU |
51433 | 6/14/2017 | 1:55:00 PM | Iron | 410 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Copper | .65 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Phosphorus as P | 1.1 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | True Color | 120 | PCU |
51433 | 6/14/2017 | 1:55:00 PM | Escherichia coli | 112.8 | MPN/100ml |
51433 | 6/14/2017 | 1:55:00 PM | Secchi disk depth | .5 | m |
51433 | 6/14/2017 | 1:55:00 PM | Depth | .3 | m |
51433 | 6/14/2017 | 1:55:00 PM | Specific conductance | 431 | uS/cm |
51433 | 6/14/2017 | 1:55:00 PM | Aluminum | 263 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Specific conductance | 439 | uS/cm |
51433 | 6/14/2017 | 1:55:00 PM | Arsenic | 1.92 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Alkalinity, Bicarbonate as CaCO3 | 73 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Molybdenum | 3.55 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Lead | .27 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Temperature, water | 25.7 | deg C |
51433 | 6/14/2017 | 1:55:00 PM | pH | 7.2 | None |
51433 | 6/14/2017 | 1:55:00 PM | Total Organic Carbon (TOC) | 17 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Chloride | 20 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Enterococcus Group Bacteria | 384.4 | MPN/100ml |
51433 | 6/14/2017 | 1:55:00 PM | Selenium | .34 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Potassium | 5.9 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Magnesium | 18.3 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Chromium | .9 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Depth, bottom | 1.4 | m |
51433 | 6/14/2017 | 1:55:00 PM | Dissolved oxygen (DO) | 6.6 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Sodium | 23.8 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Chlorophyll a, uncorrected for pheophytin | 9.3 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Cadmium | .052 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Chlorophyll a, corrected for pheophytin | 6.4 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Nitrogen, Nitrite (NO2) + Nitrate (NO3) as N | .35 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Manganese | 48 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Dissolved Solids | 316 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Sulfur, sulfate (SO4) as SO4 | 100 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Nickel | 1.61 | ug/l |
51433 | 6/14/2017 | 1:55:00 PM | Nitrogen, ammonia as N | .051 | mg/l |
51433 | 6/14/2017 | 1:55:00 PM | Nitrogen, Kjeldahl | 1.1 | mg/l |
51426 | 5/16/2017 | 9:40:00 AM | Beryllium | .023 | ug/l |
51426 | 5/16/2017 | 9:40:00 AM | pH | 6.7 | None |
51426 | 5/16/2017 | 9:40:00 AM | Dissolved oxygen (DO) | 1.9 | mg/l |
51426 | 5/16/2017 | 9:40:00 AM | Secchi disk depth | .3 | m |
51426 | 5/16/2017 | 9:40:00 AM | Depth, bottom | .4 | m |
51426 | 5/16/2017 | 9:40:00 AM | Selenium | .28 | ug/l |
51426 | 5/16/2017 | 9:40:00 AM | Phosphorus as P | .27 | mg/l |
51426 | 5/16/2017 | 9:40:00 AM | Chlorophyll a, corrected for pheophytin | 26 | ug/l |
51426 | 5/16/2017 | 9:40:00 AM | Copper | .54 | ug/l |
51426 | 5/16/2017 | 9:40:00 AM | Nitrogen, ammonia as N | .57 | mg/l |
51426 | 5/16/2017 | 9:40:00 AM | Chlorophyll a, uncorrected for pheophytin | 33 | ug/l |
51426 | 5/16/2017 | 9:40:00 AM | Nitrogen, Kjeldahl | 1.8 | mg/l |
51426 | 5/16/2017 | 9:40:00 AM | Calcium | 31.5 | mg/l |
51426 | 5/16/2017 | 9:40:00 AM | Molybdenum | 4.97 | ug/l |
51426 | 5/16/2017 | 9:40:00 AM | Nickel | 1.58 | ug/l |
51426 | 5/16/2017 | 9:40:00 AM | Cadmium | .026 | ug/l |
51426 | 5/16/2017 | 9:40:00 AM | Specific conductance | 719 | uS/cm |
51426 | 5/16/2017 | 9:40:00 AM | Specific conductance | 713 | uS/cm |
51426 | 5/16/2017 | 9:40:00 AM | Magnesium | 8.78 | mg/l |
51426 | 5/16/2017 | 9:40:00 AM | Manganese | 17 | ug/l |
51426 | 5/16/2017 | 9:40:00 AM | Escherichia coli | 57.1 | MPN/100ml |
51426 | 5/16/2017 | 9:40:00 AM | Chloride | 97 | mg/l |
51426 | 5/16/2017 | 9:40:00 AM | Total Suspended Solids (TSS) | 24 | mg/l |
51426 | 5/16/2017 | 9:40:00 AM | Lead | .78 | ug/l |
51426 | 5/16/2017 | 9:40:00 AM | Total Organic Carbon (TOC) | 9.9 | mg/l |
51426 | 5/16/2017 | 9:40:00 AM | Hardness, Ca + Mg | 115 | mg/l |
51426 | 5/16/2017 | 9:40:00 AM | Sodium | 99.6 | mg/l |
51426 | 5/16/2017 | 9:40:00 AM | Depth | .3 | m |
51426 | 5/16/2017 | 9:40:00 AM | Antimony | .24 | ug/l |
51426 | 5/16/2017 | 9:40:00 AM | Alkalinity, Bicarbonate as CaCO3 | 145 | mg/l |
51426 | 5/16/2017 | 9:40:00 AM | Aluminum | 383 | ug/l |
51426 | 5/16/2017 | 9:40:00 AM | Turbidity | 16 | NTU |