View source: R/tsl_transform.R
tsl_transform | R Documentation |
Function for time series transformations without changes in data dimensions. Generally, functions introduced via the argument f
should not change the dimensions of the output time series list. See tsl_resample()
and tsl_aggregate()
for transformations requiring changes in time series dimensions.
This function supports a parallelization setup via future::plan()
, and progress bars provided by the package progressr.
tsl_transform(tsl = NULL, f = NULL, ...)
tsl |
(required, list) Time series list. Default: NULL |
f |
(required, transformation function) name of a function taking a matrix as input. Currently, the following options are implemented, but any other function taking a matrix as input (for example,
|
... |
(optional, additional arguments of |
time series list
Other tsl_processing:
tsl_aggregate()
,
tsl_resample()
,
tsl_smooth()
,
tsl_stats()
#two time series
tsl <- tsl_initialize(
x = fagus_dynamics,
name_column = "name",
time_column = "time"
) |>
tsl_subset(
names = c("Spain", "Sweden"),
colnames = c("rainfall", "temperature")
)
if(interactive()){
tsl_plot(
tsl = tsl
)
}
#centering and scaling
#-----------------------------------------
#same mean and standard deviation are used to scale each variable across all time series
tsl_scale <- tsl_transform(
tsl = tsl,
f = f_scale_local
)
if(interactive()){
tsl_plot(
tsl = tsl_scale,
guide_columns = 3
)
}
#rescaling to a new range
#-----------------------------------------
#rescale between -100 and 100
tsl_rescaled <- tsl_transform(
tsl = tsl,
f = f_rescale_local,
new_min = -100,
new_max = 100
)
#old range
sapply(X = tsl, FUN = range)
#new range
sapply(X = tsl_rescaled, FUN = range)
#numeric transformations
#-----------------------------------------
#eemian pollen counts
tsl <- tsl_initialize(
x = distantia::eemian_pollen,
name_column = "name",
time_column = "time"
)
if(interactive()){
tsl_plot(
tsl = tsl
)
}
#percentages
tsl_percentage <- tsl_transform(
tsl = tsl,
f = f_percent
)
if(interactive()){
tsl_plot(
tsl = tsl_percentage
)
}
#hellinger transformation
tsl_hellinger <- tsl_transform(
tsl = tsl,
f = f_hellinger
)
if(interactive()){
tsl_plot(
tsl = tsl_hellinger
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.