Simple, good-looking crosstabs that allow anonymization

84 Views Asked by At

Is there an easy way to annonymize crosstabs created with the tbl_cross function from the gtsummary package?

Or is there an alternative package that I can just use? For example, I want to anonymize all values that are >5.

1

There are 1 best solutions below

0
On

I agree with @r2evans and the aggregation should be done before passing the data to tbl_cross(). Example below!

library(gtsummary)
#> #Uighur
library(tidyverse)
packageVersion("gtsummary")
#> [1] '1.5.2'

tbl <-
  diamonds %>%
  # lump together levels with fewer than 1000 observations
  mutate(clarity = fct_lump_min(clarity, min = 1000)) %>%
  tbl_cross(clarity, color)

enter image description here Created on 2022-03-16 by the reprex package (v2.0.1)