Welcome to the first post for our 'plot of the month' category! These posts will feature code snippets that can be used to reproduce plots or maps of SWMP data. Ideally, each post should have a reproducible example that includes code to access data and to produce the plot using R. These requirements should be easy to address with the tools provided by SWMPr, although we don't want to discourage users from posting content if the requirements can't be met. Therefore, we encourage posts on anything related to the visualization of SWMP data, with the understanding that reproducible code is a desired but not required part of each post.
Plot images can be uploaded and embedded in each post as jpeg attachments. Code snippets can also be shown using the code tags from the menu above.
On to the fun stuff... This post describes how you can create a summary plot of a SWMP data variable using functions in the SWMPr package. Check out the SWMPr tab on this website for more information about this package. The code below imports station data using the import_remote function and creates the plot using the plot_summary function. You'll notice that the plot is identical those on the SWMP summary widget and these functions were in fact used to create the application.
Start by installing and loading the SWMPr package in R.
install.packages('SWMPr')
library(SWMPr)
Import site data for the plot, run qaqc filters.
dat <- import_remote('apadbwq')
dat <- qaqc(dat)
Create a summary plot for water temperature.
plot_summary(dat, param = 'temp')
And the plot...
Different parameters can be plotted by changing the param argument. The date ranges can also be changed with the years argument. More information about the plot_summary command can be found in the help file from the package. Just run ?plot_summary to see the file.
Cheers,
Marcus