Package 'twriTemplates'

Title: Templates for TWRI reports
Description: Provides word and pdf Rmarkdown templates that meet TWRI branding guidance.
Authors: Michael Schramm [aut, cre] , Texas Water Resources Institute [cph], Laura DeCicco [ctb] ('ggplot_box_legend()')
Maintainer: Michael Schramm <[email protected]>
License: CC0
Version: 0.3.0
Built: 2024-11-11 05:31:23 UTC
Source: https://github.com/TxWRI/twriTemplates

Help Index


Water quality data from two sites on the Arroyo Colorado

Description

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.

Usage

data(arroyo_wetland)

Format

A data frame with 7005 rows and 13 variables:

basin_id

two digit basin identifier

segment_id

TCEQ segment identifier

on_segment

data flag indicating location of station

rfa_tag_id

trip identifer, records with the same value were collected on the same trip and location

station_id

station identifier

end_date

monitoring trip date

end_time

time of collection

end_depth

depth sample was collected at

monitoring_type

monitoring type codes are used to distinguish monitoring purporse. TCEQ DMRG includes a record and description of type codes

parameter_code

distinct parameter codes described below

greater_than_less_than

censored data flag; "<" indicates below the minimum detection limit, ">" indicates above the maximum detection limit

value

measured value

mdl

minimum detection limit reported by the lab

Details

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

Source

TCEQ SWQMIS database.


Dissolved oxygen measurements from the Tres Palacios river

Description

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.

Usage

data(dissolved_oxygen)

Format

A data frame with 236 rows and 6 variables:

station_id

unique water quality monitoring station identifier

end_date

sampling date in yyyy-mm-dd format

parameter_code

unique parameter code

parameter_description

parameter description with units

average_do

mean of dissolved oxygen measurement, in mg/L

min_do

minimum of dissolved oxygen measurement, in mg/L

Source

https://www80.tceq.texas.gov/SwqmisWeb/public/crpweb.faces#


Temperature and precipitation data at Easterwood Airport

Description

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.

Usage

data(easterwood_weather)

Format

A data frame with 4045 rows and 5 variables:

station

station identifier

date

sampling date in yyyy-mm-dd format

name

station name

dailymaximumdrybulbtemperature

daily maximum tempreature in degrees F.

dailyprecipitation

daily total precipitation in inches

Source

https://www.ncei.noaa.gov/cdo-web/datasets/GHCND/stations/GHCND:USW00003904/detail


Get names of all unique palettes provided in twriTemplates

Description

Get names of all unique palettes provided in twriTemplates

Usage

get_twri_palettes(full = FALSE)

Arguments

full

Whether to include full palette names (with suffixes, e.g. _cont) or just stubs

Value

Vector of palette name stubs or full names

Examples

get_twri_palettes()

Create a Boxplot Legend

Description

Create a legend that explains the features of a boxplot. Can be added easily to existing ggplots using plot_grid or plot_arithmetic.

Usage

ggplot_box_legend(
  font_family = "OpenSansCondensed_TWRI",
  point_label = " - Measured values"
)

Arguments

font_family

defaults to "OpenSansCondensed_TWRI". Can be modified to any locally installed font.

point_label

character string - how you want to label to point in a legend. If you overlay measured points in the box plot, " - Measured values" is appropriate. If the points only indicate outliers, " - values outside the\ninterquartile range" is appropriate. This can be custoimized as necessary. Use "\n" to indicate where a line break should occur.

Value

a ggplot object

Author(s)

Laura DeCicco

References

https://waterdata.usgs.gov/blog/boxplots/

Examples

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()

Open and install fonts

Description

Helper function to open font folders in your GUI so you can install fonts for local use.

Usage

install_font(font)

Arguments

font

one of c("CrimsonPro","OpenSansCondensed")

Value

Hopefully nothing

Examples

install_font("CrimsonPro")

Water quality data for Mission and Aransas National Estuarine Research Reserve (NERR)

Description

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.

Usage

data(mission_aransas_nerr)

Format

A data frame with 140352 rows and 10 variables:

StationCode

station identifier, factor with levels marabwq and marcewq for Aransas Bay and Copano East stations respectively.

DateTimeStamp

sampling date-time in yyyy-mm-dd hh:mm::ss format.

Temp

water temperature in degrees Celsius.

F_Temp

data qualifier, <0> indicates approved data.

SpCond

specific conductance in µS/cm.

F_SpCond

data qualifier, <0> indicates approved data.

Sal

Salinity in ppt.

F_Sal

data qualifier, <0> indicates approved data.

DO_mgl

dissolved oxygen in mg/L.

F_DO_mgl

data qualifier, <0> indicates approved data.

Source

NOAA National Estuarine Research Reserve System (NERRS). 2022. System-Wide Monitoring Program. NOAA NERRS Centralized Data Management Office. https://cdmo.baruch.sc.edu/.


Discharge measurements from field-based surveys

Description

Includes field based stream discharge and stage measurements at the Como Creek NEON field station.

Usage

data(neon_stage_discharge)

Format

A data frame with 134 rows and 36 variables. Primary variables of interest include:

averageVelocityUnits
averageVelocityUnitsQF
collectDate
collectedBy
dataQF
dischargeUnitsQF
domainID
filterParamTime
finalDischarge

Corrected measured stream discharge

flowCalcQF
flowCalculation
handheldDeviceID
lowVelocityFinalQF
namedLocation
profileName
publicationDate
recorduid
release
samplingProtocolVersion
siteID
stageImpractical
startDate
stationEntryTest
streamStage

Measured stream stage in meters

streamStageUnits
streamStageUnitsQF
tapeDistanceUnits
tapeDistanceUnitsQF
totalDischarge
totalDischargeCalcQF
totalDischargeUnits
uid
velocitySensorID
waterDepthUnits
waterDepthUnitsQF
waterEdge

Source

NEON (National Ecological Observatory Network). n.d. Discharge Field Collection (DP1.20048.001), RELEASE-2022. doi:10.48443/eaak-tt31.


Get file path to example data

Description

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().

Usage

path_to_file(file = NULL)

Arguments

file

Name of the file in quotes with extension; "arroyo_swqm.txt", "dissolved_oxygen_raw.csv", "easterwood.csv", "marabwq2021.csv", or "marcewq2021.csv" will work. If NULL, the example files will be listed.

Value

file path

Source

This function is adapted from readxl::readxl_example()

Examples

path_to_file()
path_to_file("easterwood.csv")
head(read.csv(path_to_file("easterwood.csv")))

Custom color and fill scales

Description

Custom coloring and filling functions based on unique color palettes

Usage

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", ...)

Arguments

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

Details

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


a ggplot2 theme formatted in the TWRI style for presentations

Description

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.

Usage

theme_TWRI_pres(
  base_size = 16,
  base_family = "Oswald_TWRI",
  base_line_size = 1,
  base_rect_size = 1
)

Arguments

base_size

default text size in px

base_family

defaults to "Moriston_personal". Generally, use a sensible sans serif font that is available on your system.

base_line_size

default line size

base_rect_size

default rect size


a ggplot2 theme formatted in the TWRI style

Description

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.

Usage

theme_TWRI_print(
  base_size = 9.5,
  base_family = "OpenSansCondensed_TWRI",
  base_line_size = 0.5,
  base_rect_size = 0.5
)

Arguments

base_size

default text size in px

base_family

defaults to "OpenSansCondensed_TWRI". Which is provided in the package. Generally, use a sensible sans serif font that is available on your system.

base_line_size

default line size

base_rect_size

default rect size


RMD docx template for TWRI

Description

[Deprecated]

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.

Usage

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",
  ...
)

Arguments

base_format

character, either rmarkdown::word_document or bookdown::word_document2 (default)

tables

empty list, used by officedown::rdocx_document()

plots

empty list, used by officedown::rdocx_document()

lists

empty list, used by officedown::rdocx_document()

mapstyles

empty list, used by officedown::rdocx_document()

page_size

empty list, used by officedown::rdocx_document()

page_margins

empty list, used by officedown::rdocx_document()

reference_num

if TRUE text for references to sections will be the section number. If FALSE the text for references to sections will be the section title. Default is TRUE.

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 officedown::rdocx_document()


TWRI complementary color palette

Description

This is a test palette

Usage

twri_pal

twri_pal_op

twri_pal_cont

twri_pal_div

Format

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.


RMD PDF Template for TWRI

Description

Loads an Rmarkdown template that will produce a pdf document consistent with institute brand guidance.

Usage

twri_pdf(
  toc = TRUE,
  toc_depth = 2,
  number_sections = TRUE,
  latex_engine = "lualatex",
  ...
)

Arguments

toc

Logical

toc_depth

numeric

number_sections

logical

latex_engine

character, one of "pdflatex", "lualatex", or "xelatex"

...

arguments passed to pdf_document


Uranium and total dissolved solids

Description

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.

Usage

data(uranium_tds)

Format

A data frame with 44 rows and 4 variables:

tds

Total dissolved solids in mg/L

uranium

Uranium concentration in ppb

hco3

cation composition percent milliequivalents

definition

not documented

Source

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