'Simple, good-looking crosstabs that allow anonymization

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.



Solution 1:[1]

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)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Daniel D. Sjoberg