#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
)
}
Run the code above in your browser using DataLab