seasonal_barplot {SWMPrExtension}R Documentation

Cumulative Bar Plot

Description

Cumulative bar plot over a historic range

Usage

seasonal_barplot(swmpr_in, ...)

## S3 method for class 'swmpr'
seasonal_barplot(
  swmpr_in,
  param = NULL,
  hist_rng = NULL,
  log_trans = FALSE,
  converted = FALSE,
  hist_avg = TRUE,
  bar_position = "stack",
  season_facet = FALSE,
  plot_title = FALSE,
  plot = TRUE,
  ...
)

Arguments

swmpr_in

input swmpr object

...

additional arguments passed to other methods. See assign_season

param

chr string of variable to plot

hist_rng

numeric vector, if historic range is not specified then the min/max values of the data set will be used.

log_trans

logical, should y-axis be log? Defaults to FALSE

converted

logical, were the units converted from the original units used by CDMO? Defaults to FALSE. See y_labeler for details.

hist_avg

logical, should a historical average be included? Defaults to TRUE.

bar_position

chr string, options available are stack or dodge. Defaults to stack

season_facet

logical, should plot be faceted by season? Defaults to FALSE.

plot_title

logical, should the station name be included as the plot title? Defaults to FALSE

plot

logical, should a plot be returned? Defaults to TRUE

Details

This function uses barplots to summarize parameters that are best viewed on a cumulative basis (e.g., precipitation). Data are aggregated on a seasonal and annual basis.

There are two ways to make interannual comparisons: on an aggregate basis and on a seasonal basis. If the argument season_facet = FALSE then parameter totals from each season will be added together to compose one, multi-color bar.If season_facet = TRUE then parameter totals from each season separated into multiple plots for easier intra-season comparison across years.

Value

A ggplot object

Author(s)

Julie Padilla

See Also

ggplot, assign_season, y_labeler

Examples

data(apaebmet)
dat <- qaqc(apaebmet, qaqc_keep = c('0', '3', '5'))

x <- seasonal_barplot(dat, param = 'totprcp'
                      , season_grps = list(c(1,2,3), c(4,5,6), c(7,8,9), c(10, 11, 12))
                      , season_names = c('Winter', 'Spring', 'Summer', 'Fall')
                      , hist_avg = TRUE
                      , converted = FALSE)


# return a table instead of a figure
y <- seasonal_barplot(dat, param = 'totprcp'
                      , season_grps = list(c(1,2,3), c(4,5,6), c(7,8,9), c(10, 11, 12))
                      , season_names = c('Winter', 'Spring', 'Summer', 'Fall')
                      , converted = FALSE
                      , plot = FALSE)

## divide plot into seasonal facets
z <- seasonal_barplot(dat, param = 'totprcp'
                      , season_grps = list(c(1,2,3), c(4,5,6), c(7,8,9), c(10, 11, 12))
                      , season_names = c('Winter', 'Spring', 'Summer', 'Fall')
                      , season_facet = TRUE
                      , hist_avg = TRUE
                      , converted = FALSE)

## convert from mm to in
dat$totprcp <- dat$totprcp / 25.4

x1 <- seasonal_barplot(dat, param = 'totprcp'
                      , season_grps = list(c(1,2,3), c(4,5,6), c(7,8,9), c(10, 11, 12))
                      , season_names = c('Winter', 'Spring', 'Summer', 'Fall')
                      , hist_avg = TRUE
                      , converted = TRUE)


[Package SWMPrExtension version 2.2.5.1 Index]