Learn R Programming

hydroToolkit (version 0.1.0)

subset_hydroMet: Subset your data

Description

This method allows you to easily cut the data stored in an hydroMet_XXX class object by dates.

Usage

subset_hydroMet(obj, slot_name, from = NULL, to = NULL)

# S4 method for hydroMet_BDHI subset_hydroMet(obj, slot_name, from = NULL, to = NULL)

# S4 method for hydroMet_DGI subset_hydroMet(obj, slot_name, from = NULL, to = NULL)

# S4 method for hydroMet_CR2 subset_hydroMet(obj, slot_name, from = NULL, to = NULL)

# S4 method for hydroMet_IANIGLA subset_hydroMet(obj, slot_name, from = NULL, to = NULL)

# S4 method for hydroMet_compact subset_hydroMet(obj, slot_name, from = NULL, to = NULL)

Arguments

obj

an hydroMet_XXX class object.

slot_name

string vector with the slot(s) name(s) to subset. NOTE: in case you want to subset a hydroMet_IANIGLA object is recommended to consider all the slots with data.

from

string (or POSIXct - valid only in 'BDHI' and 'IANIGLA') with the starting Date. You can use from without to. In this case you will subset your data 'from' till the end.

to

string (or POSIXct - valid only in 'BDHI' and 'IANIGLA') with the ending 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 provided in obj but subsetted.

Functions

  • subset_hydroMet,hydroMet_BDHI-method: subset method for BDHI data

  • subset_hydroMet,hydroMet_DGI-method: subset method for DGI data

  • subset_hydroMet,hydroMet_CR2-method: subset method for CR2 data

  • subset_hydroMet,hydroMet_IANIGLA-method: subset method for IANIGLA data

  • subset_hydroMet,hydroMet_compact-method: subset method for compact data

Examples

Run this code
# NOT RUN {
# Create BDHI hydro-met station
guido <- create_hydroMet(class_name = 'BDHI')

# List with meteorological variables (slots in BDHI's object)
cargar <- list('precip', 'Qmd', 'Qmm')

# Assign as names the files
hydro_files   <- list.files( system.file('extdata', package = "hydroToolkit"), pattern = 'Guido' )
names(cargar) <- hydro_files

# Build the object with the met records
guido <- build_hydroMet(obj = guido, slot_list = cargar, 
               path = system.file('extdata', package = "hydroToolkit") )
               
# Subset daily mean discharge
guido <- subset_hydroMet(obj = guido, slot_name = 'Qmd', from = '2005-01-01',
            to = '2010-12-31')

# }

Run the code above in your browser using DataLab