-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
t1flex removes column headers for extra.col in version 1.5.1. I wrote a function to add back column headers below:
table1 = function(...) {
tbl = table1::table1(...)
obj = attr(tbl, "obj", exact=TRUE)
tbl = table1::t1flex(tbl) %>%
flextable::theme_zebra() %>%
flextable::set_table_properties(layout="autofit")
# change less than symbol to html encoded version
for(i in 1:length(tbl$body$content$data)) {
tmp = tbl$body$content$data[[i]]
tmp$txt = gsub("<", "<", tmp$txt)
tbl$body$content$data[[i]] = tmp
}
# Add back column headers
for(idx in which(names(obj$headings) == "")) {
tbl$header$dataset[1,idx+1] = obj$headings[idx]
tbl$header$content$data[[idx+1]]$txt = obj$headings[idx]
}
tbl
}
Might be related to:
https://github.com/benjaminrich/table1/blob/6de79c2ea5b9a96f469fbc77906cc690475ce8ea/R/table1.R#L1265C1-L1265C55
Might need a check if names(headings) == "", something like:
headings <- ifelse(names(headings)=="", headings, names(headings))
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels