cum_sum {hydrotoolbox} | R Documentation |
Cumulative sum
Description
The function supports NA_real_
values. It could be very
useful when dealing with incomplete precipitation series.
Usage
cum_sum(x, col_name, out_name = NULL)
Arguments
x |
data frame or tibble with class |
col_name |
string with column(s) name(s) where to apply the function. |
out_name |
optional. String with new column(s) name(s). If you set it
as |
Value
The same table but with the new series.
Examples
## Not run:
# set path to file
path <- system.file('extdata', 'ianigla_cuevas.csv',
package = 'hydrotoolbox')
# read the file and add the new column with cumulative precipitation
cuevas <-
read_ianigla(path = path) %>%
cum_sum(col_name = 'Precip_Total', out_name = 'p_cum')
# plot it
plot(x = cuevas[ , 'date', drop = TRUE],
y = cuevas[ , 'p_cum', drop = TRUE],
col = 'red', type = 'l',
xlab = 'Date', ylab = 'Pcum(mm)')
## End(Not run)
[Package hydrotoolbox version 1.1.2 Index]