stan-dev / stan-dev/posterior

In summarise draws, a function that returns a character changes all columns to character

Open
#355 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
R
Stars
171
Forks
26
Avg merge
2d 18h
Merged PRs (30d)
3

Description

If a summary function that returns a character is used in summarise_draws, it makes all columns <chr> which messes up formatting.

example_draws() |>
   summarise_draws(char_fun = \(x) "word", mean)

Returns

# A tibble: 10 × 3
   variable char_fun      mean
   <chr>    <chr>         <chr>
 1 mu       word          4.1799990610081
 2 tau      word          4.16356885610418
 3 theta[1] word          6.74893947963962
 4 theta[2] word          5.25331634990726
 5 theta[3] word          3.04393475572924
 6 theta[4] word          4.85842854299997
 7 theta[5] word          3.22258991784476
 8 theta[6] word          3.98696993634695
 9 theta[7] word          6.5030995214442
10 theta[8] word          4.56520199862817

This could be fixed by using type.convert(out, as.is = TRUE) on the output tibble in summarise_draws_helper

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the example with summarise_draws and inspect summarise_draws_helper, the entry point named in the issue. Check the existing tests around summary output, then verify that a character-valued summary no longer changes numeric columns to character while the character result remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.