atorus-research / Tplyr

Home Page:https://atorus-research.github.io/Tplyr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom title for nested count summary

johanneswerner opened this issue · comments

Description

I am trying to understand if it is possible to change the repeating value from the first column to something such as "Total".

I am using the Nested Count Summaries example

tplyr_table(adae, TRTA) %>%
  add_layer(
    group_count(vars(AEBODSYS, AEDECOD))
  ) %>%
  build() %>%
  head() %>% 
  kable()

Is it possible (and if so how) to change the value in row_label2 for the "title of row_label1 to change this to something like "Total" instead of repeating the value from row_label1 (see box in image below)?

Unsaved Image 1

Hi @johanneswerner. We don't have a built in function to handle this. I think it would be easiest to handle this as a post-process.

dat %>%
  mutate(
    row_label2 = if_else(row_label1==row_label2, "Total", row_label2)
)