set_value | R Documentation |
Specify specific values between dates.
set_value(x, col_name, out_name = NULL, value, from, to)
x |
data frame or tibble with class |
col_name |
string with column(s) name(s) to set. |
out_name |
optional. String with new column(s) name(s). If you set it
as |
value |
numeric vector with the numeric values to set between
dates ( |
from |
string vector for |
to |
string vector for |
The same table but with the set numeric values between the dates.
# create a data frame
dates <- seq.Date(from = as.Date('1990-01-01'), to = as.Date('1990-12-01'), by = 'm')
met_var <- runif(n = 12, 0, 10)
met_table <- data.frame(dates, met_var)
# set single value recycling
set_value(x = met_table, col_name = 'met_var', value = 10,
from = '1990-01-01', to = '1990-06-01' )
# set different periods
set_value(x = met_table, col_name = 'met_var', value = list(NA_real_, c(1, 2) ),
from = c('1990-01-01', '1990-11-01'), to = c('1990-06-01', '1990-12-01') )
# now set as new columns
set_value(x = met_table, col_name = 'met_var', out_name = 'met_set',
value = list(NA_real_, c(1, 2) ),
from = c('1990-01-01', '1990-11-01'),
to = c('1990-06-01', '1990-12-01') )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.