Describe your issue
Hello! I frequently encounter datasets where values are not presentation-ready like in the dataset below:
demo_data <- data.frame(
stringsAsFactors = FALSE,
sex = c("m","m","m",
"m","m","m","m","m","f",
"m"),
case_classification = c("prob","susp","prob",
"susp","susp","susp","susp","susp","susp","susp")
)
When I create a table for presentation, I am able to manipulate column labels with cols_label()
for {gt} or set_header_labels()
for {flextable}. However, I canβt seem to find an option for either to change the row labels for example:
In sex,
m to βMaleβ
f to βFemaleβ
In case_classification
susp to βSuspectβ
prob to βProbableβ
What steps have you already taken to find an answer?
What I am doing now is to recode values, for example:
demo_data <- demo_data %>% mutate(sex = recode(sex, "m" = "Male"))
Is it possible to βrecodeβ or change row labels as you are constructing the table for presentation already? It does not look like it is possible for {flextable}, while for {gt} you can only add row group labels with tab_row_group()
.