@@ -313,11 +313,15 @@ mcmc_rank_overlay <- function(x,
313313
314314 # Now ensure that all combinations of parameter, chain, and bin_start exist
315315 # even if no counts are present (https://github.com/stan-dev/bayesplot/issues/331)
316- all_params_chains <- dplyr :: distinct(data , .data $ parameter , .data $ chain )
317- all_bins <- dplyr :: distinct(histobins , .data $ bin_start , .data $ cut )
318- combos <- dplyr :: cross_join(all_params_chains , all_bins )
319- d_bin_counts <- full_join(combos , d_bin_counts , by = c(" parameter" , " chain" , " bin_start" )) %> %
320- mutate(n = dplyr :: coalesce(n , 0L ))
316+ all_combos <- dplyr :: as_tibble(expand.grid(
317+ parameter = unique(data $ parameter ),
318+ chain = unique(data $ chain ),
319+ bin_start = unique(histobins $ bin_start ),
320+ stringsAsFactors = FALSE
321+ ))
322+ d_bin_counts <- all_combos %> %
323+ left_join(d_bin_counts , by = c(" parameter" , " chain" , " bin_start" )) %> %
324+ mutate(n = dplyr :: if_else(is.na(n ), 0L , n ))
321325
322326 # Duplicate the final bin, setting the left edge to the greatest x value, so
323327 # that the entire x-axis is used,
0 commit comments