From 90fa42c86596c85168931148bf8d5fa014fa7794 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 23 Jul 2020 10:51:39 +0200 Subject: Update docs, use R6 support of roxygen --- R/TOXSWA_cwa.R | 56 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 21 deletions(-) (limited to 'R/TOXSWA_cwa.R') diff --git a/R/TOXSWA_cwa.R b/R/TOXSWA_cwa.R index 42cdd35..6521349 100644 --- a/R/TOXSWA_cwa.R +++ b/R/TOXSWA_cwa.R @@ -142,35 +142,24 @@ plot.TOXSWA_cwa <- function(x, time_column = c("datetime", "t", "t_firstjan", "t #' R6 class for holding TOXSWA water concentration data and associated statistics #' -#' An R6 class for holding TOXSWA water concentration (cwa) data and some associated statistics. -#' Usually, an instance of this class will be generated by \code{\link{read.TOXSWA_cwa}}. +#' @description An R6 class for holding TOXSWA water concentration (cwa) data +#' and some associated statistics. like maximum moving window average +#' concentrations, and dataframes holding the events exceeding specified +#' thresholds. Usually, an instance of this class will be generated +#' by \code{\link{read.TOXSWA_cwa}}. #' -#' @docType class -#' @importFrom R6 R6Class #' @export #' @format An \code{\link{R6Class}} generator object. -#' @field filename Length one character vector. -#' @field basedir Length one character vector. +#' @field filename Length one character vector holding the filename. +#' @field basedir Length one character vector holding the directory where the file came from. +#' @field zipfile If not null, giving the path to the zip file from which the file was read. #' @field segment Length one integer, specifying for which segment the cwa data were read. +#' @field substance The TOXSWA name of the substance. #' @field cwas Dataframe holding the concentrations. #' @field events List of dataframes holding the event statistics for each threshold. #' @field windows Matrix of maximum time weighted average concentrations (TWAC_max) #' and areas under the curve in µg/day * h (AUC_max_h) or µg/day * d (AUC_max_d) #' for the requested moving window sizes in days. -#' @section Methods: -#' \describe{ -#' \item{\code{get_events(threshold, total = FALSE)}}{ -#' Populate a datataframe with event information for the specified threshold value -#' in µg/L. If \code{total = TRUE}, the total concentration including the amount -#' adsorbed to suspended matter will be used. The resulting dataframe is stored in the -#' \code{events} field of the object. -#' } -#' \item{\code{moving_windows(windows, total = FALSE)}}{ -#' Add to the \code{windows} field described above. -#' Again, if \code{total = TRUE}, the total concentration including the amount -#' adsorbed to suspended matter will be used. -#' } -#' } #' @examples #' H_sw_R1_stream <- read.TOXSWA_cwa("00003s_pa.cwa", #' basedir = "SwashProjects/project_H_sw/TOXSWA", @@ -180,7 +169,6 @@ plot.TOXSWA_cwa <- function(x, time_column = c("datetime", "t", "t_firstjan", "t #' H_sw_R1_stream$moving_windows(c(7, 21)) #' print(H_sw_R1_stream) #' @keywords data - TOXSWA_cwa <- R6Class("TOXSWA_cwa", public = list( filename = NULL, @@ -191,6 +179,15 @@ TOXSWA_cwa <- R6Class("TOXSWA_cwa", cwas = NULL, windows = NULL, events = list(), + + #' @description + #' Create a TOXSWA_cwa object from a file + #' @param filename The filename + #' @param basedir The directory to look in + #' @param zipfile Optional path to a zipfile holding the file + #' @param segment Either "last" or the number of the segment for which to read the data + #' @param substance The TOXSWA substance name (for TOXSWA 4 or higher) + #' @param total Should total concentrations be read in? If FALSE, free concentrations are read initialize = function(filename, basedir, zipfile = NULL, segment = "last", substance = "parent", total = FALSE) { self$filename <- filename @@ -327,6 +324,12 @@ TOXSWA_cwa <- R6Class("TOXSWA_cwa", } } }, + + #' @description + #' Add to the `windows` field described above. + #' @param windows Window sizes in days + #' @param total If TRUE, the total concentration including the amount adsorbed to + #' suspended matter will be used. moving_windows = function(windows, total = FALSE) { window_names = paste(windows, "days") n = length(window_names) @@ -350,6 +353,14 @@ TOXSWA_cwa <- R6Class("TOXSWA_cwa", } invisible(self) }, + + #' @description + #' Populate a datataframe with event information for the specified + #' threshold value. The resulting dataframe is stored in the `events` + #' field of the object. + #' @param thresholds Threshold values in µg/L. + #' @param total If TRUE, the total concentration including the amount adsorbed to + #' suspended matter will be used. get_events = function(thresholds, total = FALSE) { if (missing(thresholds)) { stop("You need to specify at least one threshold concentration in \u03bcg/L") @@ -397,6 +408,9 @@ TOXSWA_cwa <- R6Class("TOXSWA_cwa", } invisible(self) }, + + #' @description + #' Print a `TOXSWA_cwa` object print = function() { cat(" data from file", self$filename, "segment", self$segment, "\n") print(head(self$cwas)) -- cgit v1.2.1