View source: R/utils_new_time.R
utils_new_time | R Documentation |
Internal function called by tsl_aggregate()
and tsl_resample()
to help transform the input argument new_time
into the proper format for time series aggregation or resampling.
utils_new_time(tsl = NULL, new_time = NULL, keywords = "aggregate")
utils_new_time_type(
tsl = NULL,
new_time = NULL,
keywords = c("resample", "aggregate")
)
tsl |
(required, list) Time series list. Default: NULL |
new_time |
(required, zoo object, numeric, numeric vector, Date vector, POSIXct vector, or keyword) breakpoints defining aggregation groups. Options are:
|
keywords |
(optional, character string or vector) Defines what keywords are returned. If "aggregate", returns valid keywords for |
Vector of class numeric, Date, or POSIXct
Other internal_time_handling:
utils_as_time()
,
utils_coerce_time_class()
,
utils_is_time()
,
utils_time_keywords()
,
utils_time_keywords_dictionary()
,
utils_time_keywords_translate()
,
utils_time_units()
#three time series
#climate and ndvi in Fagus sylvatica stands in Spain, Germany, and Sweden
tsl <- tsl_initialize(
x = fagus_dynamics,
name_column = "name",
time_column = "time"
)
# new time for aggregation using keywords
#-----------------------------------
#get valid keywords for aggregation
tsl_time_summary(
tsl = tsl,
keywords = "aggregate"
)$keywords
#if no keyword is used, for aggregation the highest resolution keyword is selected automatically
new_time <- utils_new_time(
tsl = tsl,
new_time = NULL,
keywords = "aggregate"
)
new_time
#if no keyword is used
#for resampling a regular version
#of the original time based on the
#average resolution is used instead
new_time <- utils_new_time(
tsl = tsl,
new_time = NULL,
keywords = "resample"
)
new_time
#aggregation time vector form keyword "years"
new_time <- utils_new_time(
tsl = tsl,
new_time = "years",
keywords = "aggregate"
)
new_time
#same from shortened keyword
#see utils_time_keywords_dictionary()
utils_new_time(
tsl = tsl,
new_time = "year",
keywords = "aggregate"
)
#same for abbreviated keyword
utils_new_time(
tsl = tsl,
new_time = "y",
keywords = "aggregate"
)
#from a integer defining a time interval in days
utils_new_time(
tsl = tsl,
new_time = 365,
keywords = "aggregate"
)
#using this vector as input for aggregation
tsl_aggregated <- tsl_aggregate(
tsl = tsl,
new_time = new_time
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.