These functions translate ggdist/tidybayes-style data frames to/from different data frame formats (each format using a different naming scheme for its columns).

to_broom_names(data)

from_broom_names(data)

to_ggmcmc_names(data)

from_ggmcmc_names(data)

Arguments

data

A data frame to translate.

Value

A data frame with (possibly) new names in some columns, according to the translation scheme described in Details.

Details

Function prefixed with to_ translate from the ggdist/tidybayes format to another format, functions prefixed with from_ translate from that format back to the ggdist/tidybayes format. Formats include:

to_broom_names() / from_broom_names():

  • .variable <-> term

  • .value <-> estimate

  • .prediction <-> .fitted

  • .lower <-> conf.low

  • .upper <-> conf.high

to_ggmcmc_names() / from_ggmcmc_names():

  • .chain <-> Chain

  • .iteration <-> Iteration

  • .variable <-> Parameter

  • .value <-> value

Author

Matthew Kay

Examples


library(dplyr)

data(RankCorr_u_tau, package = "ggdist")

df = RankCorr_u_tau %>%
  dplyr::rename(.variable = i, .value = u_tau) %>%
  group_by(.variable) %>%
  median_qi(.value)

df
#> # A tibble: 3 x 7
#>   .variable .value .lower .upper .width .point .interval
#>       <int>  <dbl>  <dbl>  <dbl>  <dbl> <chr>  <chr>    
#> 1         1   5.62   3.86   8.03   0.95 median qi       
#> 2         2   5.48   3.46   9.07   0.95 median qi       
#> 3         3   4.96   3.10   7.86   0.95 median qi       

df %>%
  to_broom_names()
#> # A tibble: 3 x 7
#>    term estimate conf.low conf.high .width .point .interval
#>   <int>    <dbl>    <dbl>     <dbl>  <dbl> <chr>  <chr>    
#> 1     1     5.62     3.86      8.03   0.95 median qi       
#> 2     2     5.48     3.46      9.07   0.95 median qi       
#> 3     3     4.96     3.10      7.86   0.95 median qi