subset.swmpr | R Documentation |
Subset a swmpr object by a date range, parameters, or non-empty values
## S3 method for class 'swmpr'
subset(
x,
subset = NULL,
select = NULL,
operator = NULL,
rem_rows = FALSE,
rem_cols = FALSE,
...
)
x |
input swmpr object |
subset |
chr string of form 'YYYY-mm-dd HH:MM' to subset a date range. Input can be one (requires |
select |
chr string of parameters to keep, |
operator |
chr string specifiying binary operator (e.g., |
rem_rows |
logical indicating if rows with no data are removed, default |
rem_cols |
is logical indicating if cols with no data are removed, default |
... |
arguments passed to other methods |
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., %Y-%m-%d %H:%M
in POSIX standards). Be aware that an error may be returned using this function if the subset argument is in the correct format but the calendar date does not exist, e.g. '2012-11-31 12:00'
. The function can also be used to remove rows and columns that do not contain data, which may be useful after processing with other functions.
Returns a swmpr object as a subset of the input. The original object will be returned if no arguments are specified.
subset
## 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'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.