Learn R Programming

SWMPr (version 2.1.5)

subset.swmpr: Subset a swmpr object

Description

Subset a swmpr object by a date range, parameters, or non-empty values

Usage

"subset"(x, subset = NULL, select = NULL, operator = NULL, rem_rows = FALSE, rem_cols = FALSE, ...)

Arguments

x
input swmpr object
subset
chr string of form 'YYYY-mm-dd HH:MM' to subset a date range. Input can be one (requires operator or two values (a range).
select
chr string of parameters to keep, 'datetimestamp' will always be kept
operator
chr string specifiying binary operator (e.g., '>', '<='< code="">) if subset is one date value
rem_rows
logical indicating if rows with no data are removed, default FALSE
rem_cols
is logical indicating if cols with no data are removed, default FALSE
...
arguments passed to other methods

Value

Returns a swmpr object as a subset of the input. The original object will be returned if no arguments are specified.

Details

This function is used to subset swmpr data by date and/or a selected parameter. The date can be a single value or as two dates to select records within the range. The former case requires a binary operator input as a character string passed to the argument, such as > or <. The subset argument for the date(s) must also be a character string of the format YYYY-mm-dd HH:MM for each element (i.e., `

See Also

subset

Examples

Run this code
## get data
data(apaebmet)
dat <- apaebmet

## subset records greater than or equal to a date
subset(dat, subset = '2013-01-01 0:00', operator = '>=')

## subset records within a date range, select two parameters
subset(dat, subset = c('2012-07-01 6:00', '2012-08-01 18:15'),
   select = c('atemp', 'totsorad'))

Run the code above in your browser using DataLab