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

Error in { : task 1 failed - "task 1 failed - "missing value where TRUE/FALSE needed"" #56

Closed vidarsumo closed 2 years ago

vidarsumo commented 2 years ago

I get this error quite often and it's not obvious to me what's causing it.

cluster_config_h <- compare_clusterings_configs(
  types    = c("h"),
  k        = 2:10,

  # CONTROLS
  controls = list(
    hierarchical = hierarchical_control(
      method = "all"
    )

  ),

    # PREPROCESSING
  preprocs = pdc_configs(
    type = "preproc",

    none   = list(),
    zscore = list(center = c(TRUE, FALSE))

  ),

  # DISTANCES
  distances = pdc_configs(
    type      = "distance",

    sbd       = list(),

    dtw    = list(
      step.pattern = c("symmetric1", "symmetric2")
      window.type  = c("slantedband")
      open.end     = c(TRUE, FALSE),
      open.begin   = c(TRUE, FALSE)
    )

  ),

  # CENTROIDS
  centroids = pdc_configs(
    type        = "centroid",

    hierarchical = list(
      default = list()
    )

  )

)

I have 150 time series of different length, from 12 observations to 117 observations.

vidarsumo commented 2 years ago

Sorry for posting this issue. I think I've solved the problem by simply removing all NA from the data frame

cluster_config_h$hierarchical <- cluster_config_h$hierarchical %>% drop_na()