Skip to content

mcmc_acf errors for some input types #245

@hhau

Description

@hhau

Reprex (using the github version):

library(bayesplot)
#> This is bayesplot version 1.7.2.9000
#> - Online documentation and vignettes at mc-stan.org/bayesplot
#> - bayesplot theme set to bayesplot::theme_default()
#>    * Does _not_ affect other ggplot2 plots
#>    * See ?bayesplot_theme_set for details on theme setting

mcmc_acf(
  array(
    data = rnorm(100 * 2 * 2), 
    dim = c(100, 2, 2),
    dimnames = list(
      Iteration = 1 : 100,
      Chain = 1 : 2,
      Parameter = 1 : 2
    )
  )
)
#> Error in factor(rep(1:n_param, each = n_chain * n_lags), labels = levels(data[["Parameter"]])): invalid 'labels'; length 0 should be 1 or 2

Created on 2020-10-29 by the reprex package (v0.3.0)

I think this is because here: https://github.com/stan-dev/bayesplot/blob/master/R/mcmc-diagnostics.R#L583 you directly call reshape2::melt, but you mean to call https://github.com/stan-dev/bayesplot/blob/master/R/helpers-mcmc.R#L125 (because I think you've run into this issue before somehow 🙂).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions