hm_melt | R Documentation |
hydromet_compact
class objectThis method allows you merge several tables (inside hydromet_station
and/or
hydromet_compact
class objects) into a single one and set them into the compact slot
(hydromet_compact
class object).
hm_melt(obj, melt, slot_name, col_name, out_name = NULL)
## S4 method for signature 'hydromet_compact'
hm_melt(obj, melt, slot_name, col_name, out_name = NULL)
obj |
a valid |
melt |
string vector containing the |
slot_name |
list (one element per |
col_name |
string vector with the name of the variables to keep. You must comply
the following name convention |
out_name |
optional. String vector with the output names of the final table. If you
use the default value ( |
An hydromet_compact
class object with a data frame inside the compact
slot with all variables that you provided in col_name
.
hm_melt(hydromet_compact)
: plot method for compact class
Remember that all the chosen variables should have the same temporal resolution. The method itself will not warn you about bad entries.
## Not run:
# lets say that we want to put together snow water equivalent from Toscas (dgi)
# and daily streamflow discharge from Guido (snih)
# path to all example files
path <- system.file('extdata', package = 'hydrotoolbox')
# on the first place we build the stations
# dgi file
toscas <-
hm_create() %>%
hm_build(bureau = 'dgi', path = path,
file_name = 'dgi_toscas.xlsx',
slot_name = c('swe', 'tmax',
'tmin', 'tmean', 'rh', 'patm'),
by = 'day',
out_name = c('swe', 'tmax',
'tmin', 'tmean', 'rh', 'patm') )
# snih file
guido <-
hm_create() %>%
hm_build(bureau = 'snih', path = path,
file_name = c('snih_hq_guido.xlsx',
'snih_qd_guido.xlsx'),
slot_name = c('hq', 'qd'),
by = c('none', 'day') )
# now we melt the requiered data
hm_create(class_name = 'compact') %>%
hm_melt(melt = c('toscas', 'guido'),
slot_name = list(toscas = 'swe', guido = 'qd'),
col_name = 'all',
out_name = c('swe(mm)', 'qd(m3/s)')
) %>%
hm_plot(slot_name = 'compact',
col_name = list( c('swe(mm)', 'qd(m3/s)') ),
interactive = TRUE,
line_color = c('dodgerblue', 'red'),
y_lab = c('q(m3/s)', 'swe(mm)'),
dual_yaxis = c('right', 'left')
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.