R/tidy_cmdstanr.R

Defines functions tidy_cmdstanr

Documented in tidy_cmdstanr

#' Change the structure of cmdstan output to fit tidybayes
#'
#' @param df dataframe from cmdstanr to be tidyformed
#'
#'
#' @return data.frame
#' @export
#'
#' @examples
#'
#' posterior %>% tidy_cmdstanr()
tidy_cmdstanr <- function(df) {
  df %>% dplyr::rename_with(.cols = dplyr::matches("\\.\\d"), ~ paste0(gsub(".", "[", .x, fixed = TRUE), "]"))
}
Agasax/laRs documentation built on Oct. 21, 2022, 3:09 p.m.