hm_subset: Subset your data by dates

Description Usage Arguments Value Functions Examples

Description

The method will subset the required slot.

Usage

1
2
3
4
5
6
7
hm_subset(obj, slot_name = "all", from = NULL, to = NULL)

## S4 method for signature 'hydromet_station'
hm_subset(obj, slot_name = "all", from = NULL, to = NULL)

## S4 method for signature 'hydromet_compact'
hm_subset(obj, slot_name = "all", from = NULL, to = NULL)

Arguments

obj

a valid hydromet_XXX class object.

slot_name

string vector with the name(s) of the slot(s) to subset. If you use 'all' as argument the method will subset all the variables with data.

from

string Date or POSIXct value with the starting date. You can use from without to. In this case you will subset your data from till the end.

to

string Date or POSIXct value with the starting date. You can use to without from. In this case you will subset your data from the beginning till to.

Value

The same hydromet_XXX class object provided in obj but subsetted.

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# cuevas station
path <- system.file('extdata', package = 'hydrotoolbox')

# use the build method
hm_cuevas <-
  hm_create() %>%
  hm_build(bureau = 'ianigla', path = path,
           file_name = 'ianigla_cuevas.csv',
           slot_name = c('tair', 'rh', 'patm',
                         'precip', 'wspd', 'wdir',
                         'kin', 'hsnow', 'tsoil'),
           by = 'hour',
           out_name = c('tair(°C)', 'rh(%)', 'patm(mbar)',
                        'p(mm)', 'wspd(km/hr)', 'wdir(°)',
                        'kin(kW/m2)', 'hsnow(cm)', 'tsoil(°C)' )
          )

# subset relative humidity and plot it
hm_subset(obj = hm_cuevas, slot_name = 'rh',
          from = ISOdate(2020, 2, 1),
          to = ISOdate(2020, 4, 1) ) %>%
  hm_plot(slot_name = 'rh',
          col_name = list('rh(%)'),
          interactive = TRUE,
          y_lab = 'RH(%)' )

hydrotoolbox documentation built on July 9, 2021, 1:06 a.m.