hm_subset: Subset your data by dates

hm_subsetR Documentation

Subset your data by dates

Description

The method will subset the required slot.

Usage

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 POSIX* 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 POSIX* 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

  • hm_subset(hydromet_station): subset method for station class

  • hm_subset(hydromet_compact): subset method for compact class

Examples

## Not run: 
# 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(%)' )

## End(Not run)


hydrotoolbox documentation built on April 14, 2023, 12:34 a.m.