Title: | Templates for TWRI reports |
---|---|
Description: | Provides word and pdf Rmarkdown templates that meet TWRI branding guidance. |
Authors: | Michael Schramm [aut, cre] |
Maintainer: | Michael Schramm <[email protected]> |
License: | CC0 |
Version: | 0.3.0 |
Built: | 2024-08-13 19:26:48 UTC |
Source: | https://github.com/TxWRI/twriTemplates |
Add logo to ggplot
add_TWRI_logo(plot, scale = 0.25, halign = 0.01, valign = 0.01)
add_TWRI_logo(plot, scale = 0.25, halign = 0.01, valign = 0.01)
plot |
ggplot object |
scale |
scale the logo, defaults to 0.25 |
halign |
aligns logo within the ggplot |
valign |
aligns the logo within the ggplot |
ggplot object
Includes water quality monitoring data from two sites on the Arroyo Colorado from 1973 through 2022. Multiple parameters are included. Station 13079 is upstream of station 13074. In 2011 a treatment wetland started operation at a wastewater treatment plant between the two stations. This data is typical of data downloaded from the TCEQ SWQMIS database.
data(arroyo_wetland)
data(arroyo_wetland)
A data frame with 7005 rows and 13 variables:
two digit basin identifier
TCEQ segment identifier
data flag indicating location of station
trip identifer, records with the same value were collected on the same trip and location
station identifier
monitoring trip date
time of collection
depth sample was collected at
monitoring type codes are used to distinguish monitoring purporse. TCEQ DMRG includes a record and description of type codes
distinct parameter codes described below
censored data flag; "<" indicates below the minimum detection limit, ">" indicates above the maximum detection limit
measured value
minimum detection limit reported by the lab
Additional details... LIST OF UNIQUE PARAMETERS
00010 TEMPERATURE, WATER (DEGREES CENTIGRADE)
00061 FLOW STREAM, INSTANTANEOUS (CUBIC FEET PER SEC)
00070 TURBIDITY, (JACKSON CANDLE UNITS)
00076 TURBIDITY,HACH TURBIDIMETER (FORMAZIN TURB UNIT)
00094 SPECIFIC CONDUCTANCE,FIELD (US/CM @ 25C)
00300 OXYGEN, DISSOLVED (MG/L)
00400 PH (STANDARD UNITS)
00530 RESIDUE, TOTAL NONFILTRABLE (MG/L)
00600 NITROGEN, TOTAL (MG/L AS N)
00610 NITROGEN, AMMONIA, TOTAL (MG/L AS N)
00620 NITRATE NITROGEN, TOTAL (MG/L AS N)
00625 NITROGEN, KJELDAHL, TOTAL (MG/L AS N)
00630 NITRITE PLUS NITRATE, TOTAL ONE LAB DETERMINED VALUE (MG/L AS N)
00665 PHOSPHORUS, TOTAL, WET METHOD (MG/L AS P)
00671 ORTHOPHOSPHATE PHOSPHORUS,DISS,MG/L,FLDFILT<15MIN
00680 CARBON, TOTAL ORGANIC, NPOC (TOC), MG/L
01351 FLOW SEVERITY:1=No Flow,2=Low,3=Normal,4=Flood,5=High,6=Dry
31616 FECAL COLIFORM,MEMBR FILTER,M-FC BROTH, #/100ML
31648 E. COLI, MTEC, MF, #/100 ML
31699 E. COLI, COLILERT, IDEXX METHOD, MPN/100ML
70507 ORTHOPHOSPHATE PHOSPHORUS,DISS,MG/L,FILTER >15MIN
72053 DAYS SINCE PRECIPITATION EVENT (DAYS)
74069 STREAM FLOW ESTIMATE (CFS)
82078 TURBIDITY,FIELD NEPHELOMETRIC TURBIDITY UNITS, N
82903 DEPTH OF BOTTOM OF WATER BODY AT SAMPLE SITE
89835 FLOW MTH 1=GAGE 2=ELEC 3=MECH 4=WEIR/FLU 5=DOPPLER
TCEQ SWQMIS database.
Data from the Texas Commission on Environmental Quality Surface Water Quality
Monitoring Information System. The Average_DO`` field is the mean of dissolved oxygen concentrations (mg/L) measured at a field site at that day. The
Min_DO' field
is the minimum dissolved oxygen concentration measured at that site on that day.
data(dissolved_oxygen)
data(dissolved_oxygen)
A data frame with 236 rows and 6 variables:
unique water quality monitoring station identifier
sampling date in yyyy-mm-dd format
unique parameter code
parameter description with units
mean of dissolved oxygen measurement, in mg/L
minimum of dissolved oxygen measurement, in mg/L
https://www80.tceq.texas.gov/SwqmisWeb/public/crpweb.faces#
Data from the National Oceanic Atmospheric Administration (NOAA) Climate Data Online for Easterwood Airport in College Station, Texas. Includes daily maximum temperature and daily precipitation records from approximately 2010 through 2017.
data(easterwood_weather)
data(easterwood_weather)
A data frame with 4045 rows and 5 variables:
station identifier
sampling date in yyyy-mm-dd format
station name
daily maximum tempreature in degrees F.
daily total precipitation in inches
https://www.ncei.noaa.gov/cdo-web/datasets/GHCND/stations/GHCND:USW00003904/detail
Get names of all unique palettes provided in twriTemplates
get_twri_palettes(full = FALSE)
get_twri_palettes(full = FALSE)
full |
Whether to include full palette names (with suffixes, e.g. |
Vector of palette name stubs or full names
get_twri_palettes()
get_twri_palettes()
Create a legend that explains the features of a boxplot. Can be added easily
to existing ggplots using plot_grid
or plot_arithmetic
.
ggplot_box_legend( font_family = "OpenSansCondensed_TWRI", point_label = " - Measured values" )
ggplot_box_legend( font_family = "OpenSansCondensed_TWRI", point_label = " - Measured values" )
font_family |
defaults to |
point_label |
character string - how you want to label to point in a
legend. If you overlay measured points in the box plot, |
a ggplot object
Laura DeCicco
https://waterdata.usgs.gov/blog/boxplots/
library(ggplot2) library(cowplot) ggplot(dissolved_oxygen) + geom_boxplot(aes(as.factor(station_id), average_do, group = station_id)) + geom_jitter(aes(as.factor(station_id), average_do, group = station_id), width = 0.1, alpha = 0.25) + theme_TWRI_print() -> p1 file <- tempfile(fileext = '.png') ragg::agg_png(file) plot_grid(p1, ggplot_box_legend(), rel_widths = c(2,1)) dev.off()
library(ggplot2) library(cowplot) ggplot(dissolved_oxygen) + geom_boxplot(aes(as.factor(station_id), average_do, group = station_id)) + geom_jitter(aes(as.factor(station_id), average_do, group = station_id), width = 0.1, alpha = 0.25) + theme_TWRI_print() -> p1 file <- tempfile(fileext = '.png') ragg::agg_png(file) plot_grid(p1, ggplot_box_legend(), rel_widths = c(2,1)) dev.off()
Helper function to open font folders in your GUI so you can install fonts for local use.
install_font(font)
install_font(font)
font |
one of |
Hopefully nothing
install_font("CrimsonPro")
install_font("CrimsonPro")
Fifteen minute water quality data. Includes station, date-time, temperature, specific conductance, salinity, and associated data qualifiers from 2020 through 2021 for the Mission and Aransas (MAR) National Estuarine Research Reserve (NERR). Data from NOAA NERRS Centralized Data Management Office.
data(mission_aransas_nerr)
data(mission_aransas_nerr)
A data frame with 140352 rows and 10 variables:
station identifier, factor with levels marabwq
and marcewq
for Aransas Bay and Copano East stations respectively.
sampling date-time in yyyy-mm-dd hh:mm::ss format.
water temperature in degrees Celsius.
data qualifier, <0> indicates approved data.
specific conductance in µS/cm.
data qualifier, <0> indicates approved data.
Salinity in ppt.
data qualifier, <0> indicates approved data.
dissolved oxygen in mg/L.
data qualifier, <0> indicates approved data.
NOAA National Estuarine Research Reserve System (NERRS). 2022. System-Wide Monitoring Program. NOAA NERRS Centralized Data Management Office. https://cdmo.baruch.sc.edu/.
Includes field based stream discharge and stage measurements at the Como Creek NEON field station.
data(neon_stage_discharge)
data(neon_stage_discharge)
A data frame with 134 rows and 36 variables. Primary variables of interest include:
Corrected measured stream discharge
Measured stream stage in meters
NEON (National Ecological Observatory Network). n.d. Discharge Field Collection (DP1.20048.001), RELEASE-2022. doi:10.48443/eaak-tt31.
twriTemplates comes with five bundled example data files in its
inst/extdata
directory. This function makes them easy to access for
practice reading with read.csv()
or readr::read_csv()
.
path_to_file(file = NULL)
path_to_file(file = NULL)
file |
Name of the file in quotes with extension; |
file path
This function is adapted from readxl::readxl_example()
path_to_file() path_to_file("easterwood.csv") head(read.csv(path_to_file("easterwood.csv")))
path_to_file() path_to_file("easterwood.csv") head(read.csv(path_to_file("easterwood.csv")))
Custom coloring and filling functions based on unique color palettes
scale_color_discrete_twri(palette = "twri", extend = FALSE, ...) scale_colour_discrete_twri(palette = "twri", extend = FALSE, ...) scale_fill_discrete_twri(palette = "twri", extend = FALSE, ...) scale_color_opinionated_twri(palette = "twri", ...) scale_colour_opinionated_twri(palette = "twri", extend = FALSE, ...) scale_fill_opinionated_twri(palette = "twri", ...) scale_color_diverging_twri(palette = "twri", ...) scale_colour_diverging_twri(palette = "twri", ...) scale_fill_diverging_twri(palette = "twri", ...) scale_color_continuous_twri(palette = "twri", ...) scale_colour_continuous_twri(palette = "twri", ...) scale_fill_continuous_twri(palette = "twri", ...)
scale_color_discrete_twri(palette = "twri", extend = FALSE, ...) scale_colour_discrete_twri(palette = "twri", extend = FALSE, ...) scale_fill_discrete_twri(palette = "twri", extend = FALSE, ...) scale_color_opinionated_twri(palette = "twri", ...) scale_colour_opinionated_twri(palette = "twri", extend = FALSE, ...) scale_fill_opinionated_twri(palette = "twri", ...) scale_color_diverging_twri(palette = "twri", ...) scale_colour_diverging_twri(palette = "twri", ...) scale_fill_diverging_twri(palette = "twri", ...) scale_color_continuous_twri(palette = "twri", ...) scale_colour_continuous_twri(palette = "twri", ...) scale_fill_continuous_twri(palette = "twri", ...)
palette |
Name of color palette |
extend |
Whether to extend discrete color palette to make sufficient colors for levels needed |
... |
Additional arguments to be passed to internal scale function |
Specific functions include:
scale_(color/colour/fill)discrete_twriDiscrete palette with either fixed or dynamically extended number of shades
scale(color/colour/fill)opinionated_twriDiscrete palette with specific values for "good", "bad", and "neutral"
scale(color/colour/fill)diverging_twriContinuous diverging color palette
scale(color/colour/fill)_continuousContinuous color palette
Provides a ggplot2 theme formatted consistent with TWRI style guidance. Figure aesthetics prioritize design and legibility for use in power point presentations. The intended output is 10 inches by 7.5 inches as 200dpi.
theme_TWRI_pres( base_size = 16, base_family = "Oswald_TWRI", base_line_size = 1, base_rect_size = 1 )
theme_TWRI_pres( base_size = 16, base_family = "Oswald_TWRI", base_line_size = 1, base_rect_size = 1 )
base_size |
default text size in px |
base_family |
defaults to |
base_line_size |
default line size |
base_rect_size |
default rect size |
Provides a ggplot2 theme formatted consistent with TWRI style guidance. Use this theme for figures intended for printed reports. The default font is "Open Sans Condensed". The suggest export width is 6.5 inches at 300 dpi.
theme_TWRI_print( base_size = 9.5, base_family = "OpenSansCondensed_TWRI", base_line_size = 0.5, base_rect_size = 0.5 )
theme_TWRI_print( base_size = 9.5, base_family = "OpenSansCondensed_TWRI", base_line_size = 0.5, base_rect_size = 0.5 )
base_size |
default text size in px |
base_family |
defaults to |
base_line_size |
default line size |
base_rect_size |
default rect size |
Development on twri_docx()
is complete. It is recommended to use
officedown::rdocx_document()
directly. This function is retained for older
templates that include the function, although rendered documents might be
inconsistent. It is suggested to update any reports to the latest version of
twriTemplates as twri_docx()
may be removed in future versions.
Loads an Rmarkdown template that will produce a Microsoft word document consistent with institute brand guidance.
twri_docx( base_format = "bookdown::word_document2", tables = list(), plots = list(), lists = list(), mapstyles = list(), page_size = list(), page_margins = list(), reference_num = TRUE, toc = FALSE, number_sections = TRUE, fig_captions = TRUE, reference_docx = "format.docx", ... )
twri_docx( base_format = "bookdown::word_document2", tables = list(), plots = list(), lists = list(), mapstyles = list(), page_size = list(), page_margins = list(), reference_num = TRUE, toc = FALSE, number_sections = TRUE, fig_captions = TRUE, reference_docx = "format.docx", ... )
base_format |
character, either |
tables |
empty list, used by |
plots |
empty list, used by |
lists |
empty list, used by |
mapstyles |
empty list, used by |
page_size |
empty list, used by |
page_margins |
empty list, used by |
reference_num |
if |
toc |
logical defaults FALSE. The template utilizes the TOC function in Word that can be manually removed or customized. |
number_sections |
logical |
fig_captions |
logical |
reference_docx |
character, specifies the template document to use. |
... |
additional arguments to |
This is a test palette
twri_pal twri_pal_op twri_pal_cont twri_pal_div
twri_pal twri_pal_op twri_pal_cont twri_pal_div
An object of class character
of length 5.
An object of class character
of length 3.
An object of class character
of length 2.
An object of class character
of length 3.
Loads an Rmarkdown template that will produce a pdf document consistent with institute brand guidance.
twri_pdf( toc = TRUE, toc_depth = 2, number_sections = TRUE, latex_engine = "lualatex", ... )
twri_pdf( toc = TRUE, toc_depth = 2, number_sections = TRUE, latex_engine = "lualatex", ... )
toc |
Logical |
toc_depth |
numeric |
number_sections |
logical |
latex_engine |
character, one of "pdflatex", "lualatex", or "xelatex" |
... |
arguments passed to pdf_document |
Example dataset from Helsel et al. (2020) that includes measured concentrations of total dissolved solids (tds) in mg/L and uranium in parts per billion from the Ogallala aquifer.
data(uranium_tds)
data(uranium_tds)
A data frame with 44 rows and 4 variables:
Total dissolved solids in mg/L
Uranium concentration in ppb
cation composition percent milliequivalents
not documented
Helsel, D.R., Hirsch, R.M., Ryberg, K.R., Archfield, S.A., and Gilroy, E.J., 2020, Statistical Methods in Water Resources - Supporting Materials: U.S. Geological Survey data release, doi:10.5066/P9JWL6XR