Is there a way to only have the 10 most frequent entries for a gtsummary tbl_summary with categorical data?
I'm currently using the following code
library(forcats)
library(dplyr)
library(magrittr)
table<- fct_count(df$name, sort = T, prop = T)%>%
slice_head(n = 10)
table$p<- round(table$p, digits = 3)
table$p<- table$p * 100
table %<>% rename(Organism = f,`%` = p)
table
Which produces a beautiful table in the console:
But ideally I would have it in a gtsummary table (because that's what the rest of my report is using). I can make the tbl_summary no problems, I just can't figure out how to limit to only the 10 most common organisms, and I haven't seen this asked/answered anywhere.
example dataset
library(AMR)
df<- data.table::as.data.table(example_isolates)
df$name<- mo_name(df$mo)




