litriv
litriv

Reputation: 36

Simple, good-looking crosstabs that allow anonymization

Is there an easy way to anonymize 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.

Upvotes: 0

Views: 85

Answers (1)

Daniel D. Sjoberg
Daniel D. Sjoberg

Reputation: 11595

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)

Upvotes: 0

Related Questions