View source: R/hydrometDiscrete.R
hydrometDiscrete | R Documentation |
Generate plots of snow survey data (SWE and depth) or other variables sampled at regular intervals (weekly or monthly).
Notice: in many cases, you're better off using the Shiny app at WRBfloods::hydroApp()
to generate and export your plot. Read on if you need additional control over the final product.
This function plots data from the local hydrometric database (maintained by the WRBdatabase package) and yields consistent-looking plots for discrete data. This function can only plot what's in the database, use the function DB_browse_ts()
to see what's in there first. Data can be represented as violin plots, as regular box plots or as a 'linedbox' plot (imitates plots currently used in the snow bulletin).
hydrometDiscrete(
location = NULL,
parameter,
startDay = 1,
endDay = 365,
tzone = "MST",
years = NULL,
title = TRUE,
plot_type = "violin",
plot_scale = 1,
save_path = NULL,
dbPath = "default",
discrete_data = NULL
)
location |
The location for which you want a plot. |
parameter |
The parameter you wish to plot. The location:parameter combo must be in the local database. |
startDay |
NOT CURRENTLY IN USE The start day of year for the plot x-axis. Can be specified as a number from 1 to 365, as a character string of form "yyyy-mm-dd", or as a date object. Either way the day of year is the only portion used, specify years to plot under parameter |
endDay |
NOT CURRENTLY IN USE The end day of year for the plot x-axis. As per |
tzone |
The timezone to use for fetching data. Datetimes are stored in the database in UTC offset, so this parameter could make a difference to what day a particular sample is considered to be on. In most cases you can ignore this parameter. |
years |
The years to plot. If |
title |
Should a title be included? |
plot_type |
Choose from "violin" , "boxplot" or "linedbox". |
plot_scale |
Adjusts/scales the size of plot text elements. 1 = standard size, 0.5 = half size, 2 = double the size, etc. Standard size works well in a typical RStudio environment. |
save_path |
Default is NULL and the graph will be visible in RStudio and can be assigned to an object. Option "choose" brings up the File Explorer for you to choose where to save the file, or you can also specify a save path directly. |
dbPath |
The path to the local hydromet database, passed to |
discrete_data |
A dataframe with the data to be plotted. Must contain the following columns: year, month, value and units. |
A .png file of the plot requested (if a save path has been selected), plus the plot displayed in RStudio. Assign the function to a variable to also get a plot in your global environment as a ggplot object which can be further modified
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.