barplot_agg: Bar Plots of Aggregated Variables

View source: R/Plot_eddy.R

barplot_aggR Documentation

Bar Plots of Aggregated Variables

Description

Creates a bar plot with aggregated variable on y-axis and labels of aggregation periods on x-axis.

Usage

barplot_agg(
  x,
  var,
  interval = NULL,
  nTicks = NULL,
  days = x$days,
  names.arg = x$Intervals
)

Arguments

x

A data frame with column names.

var

A character string. An x column name of the variable to plot on y-axis.

interval

A character string. Specifies xlab timescale and does not affect computations (e.g. "daily", "3-daily", "weekly", "monthly", etc.).

nTicks

An integer. Number of x-axis ticks to plot. If NULL, maximum 20 ticks with corresponding names.arg will be plotted, otherwise nTicks defaults to 8. Specifying nTicks allows greater control over the x-axis ticks density.

days

A numeric vector. Number of days (or their fractions) aggregated within each time interval described by names.arg. Used to specify bar widths.

names.arg

A character vector. Names of each aggregation period corresponding to x$var used as x-axis labels.

See Also

barplot

Examples

set.seed(123)
n <- 17520 # number of half-hourly records in one non-leap year
tstamp <- seq(c(ISOdate(2021,3,20)), by = "30 mins", length.out = n)
x <- data.frame(timestamp = tstamp, H = rf(n, 1, 2, 1))
aggm <- agg_sum(x, "%b-%Y")
barplot_agg(aggm, var = "H_sum", "monthly")
aggw <- agg_sum(x, "%W_%Y")
barplot_agg(aggw, var = "H_sum", "weekly")
aggd <- agg_sum(x, "%Y-%m-%d")
barplot_agg(aggd, var = "H_sum", "daily")


lsigut/openeddy documentation built on Aug. 5, 2023, 12:25 a.m.