0

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.

litriv
  • 26
  • 6
  • What do you mean with 'anonymize'? Do you want to only do the cross table on rows having values > 5 in some particular column? Do you want to just remove column and row names? – danlooo Mar 16 '22 at 10:44
  • can you share your data and code? – Mike Mar 16 '22 at 13:14
  • 3
    Anonymization can be done *before* aggregation/summarizing, I think trying to do it on the output from `gtsummary` is likely harder. – r2evans Mar 16 '22 at 13:18

1 Answers1

0

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)

Daniel D. Sjoberg
  • 8,820
  • 2
  • 12
  • 28