asardaes / dtwclust

R Package for Time Series Clustering Along with Optimizations for DTW
https://cran.r-project.org/package=dtwclust
GNU General Public License v3.0
254 stars 29 forks source link

Series order in the interactive_clustering's Explore dashboard not preserved #45

Closed lucazav closed 2 years ago

lucazav commented 4 years ago

Given my series in a list contained in the data variable, the series ordering in the Explore dashboard is the one given by sort( names(data) ) and not the original one given by names(data). This makes the analysis more difficult if you want to select your series by indexes based on your original ordering.

asardaes commented 4 years ago

I can adjust the code to avoid this. In the mean time, if you can install forcats, you can execute the following as a workaround (before executing the shiny app(s)):

trace(dtwclust::interactive_clustering, at = 12L, tracer = quote(
    server_env$.explore_df_$Series <- forcats::fct_relevel(server_env$.explore_df_$Series,
                                                           names(series))
))

trace(dtwclust::ssdtwclust, at = 14L, tracer = quote(
    server_env$.explore_df_$Series <- forcats::fct_relevel(server_env$.explore_df_$Series,
                                                           names(series))
))

I believe you must call the functions without the namespace prefix (dtwclust::) afterwards.