Learn R Programming

hydrotoolbox (version 1.1.2)

hm_subset: 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 hydromet_station hm_subset(obj, slot_name = "all", from = NULL, to = NULL)

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

Value

The same hydromet_XXX class object provided in obj but subsetted.

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.

Functions

  • hm_subset(hydromet_station): subset method for station class

  • hm_subset(hydromet_compact): subset method for compact class

Examples

Run this code
if (FALSE) {
# 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(%)' )
}

Run the code above in your browser using DataLab