Filter Yarra River water quality data
filter_yarra_data.RdThis helper function returns a filtered version of the yarra_wq dataset
(included in the yarraWQ package). It lets you select which water quality
parameter to look at (for example "pH", "temperature", "turbidity"),
and optionally limit to a single monitoring site.
Arguments
- data
A data frame with the same columns as
yarra_wq. Typically you will just passyarra_wq.- parameter_name
A string giving the parameter to filter on, for example
"pH","temperature","turbidity","dissolved_oxygen". This will be matched to theparametercolumn.- site_name
Optional. A string giving the site to filter on (matching the
namecolumn, e.g."YARRA @ CHANDLER HWY"). IfNULL(the default), all sites are included.
Value
A tibble/data.frame containing only rows that match the requested parameter and (if provided) site. If nothing matches, the returned tibble will have 0 rows.
Details
This is useful because both the plotting function (plot_yarra_metric())
and the Shiny app do the same type of filtering. Putting this logic in one
place avoids repeating the same code in multiple places.