border_matrix <- matrix(c(1, 1, 2, 0, 1, 1, 0, 0, 0), nrow = 3, ncol = 3)
ht <- huxtable::as_huxtable(
data.frame(a = c(1, 2, 3), b = c("a", "b", "c"), c = c(TRUE, FALSE, TRUE))
)
# By default adds no borders
add_bottom_borders(ht, border_matrix)
# Adds spanning borders under cells with text in the second row
add_bottom_borders(ht, transform_fns = list(spanning_borders(2)))
# Adds spanning borders under cells with text in the second row and a border
# under a cell in row 3 and column 3
add_bottom_borders(ht, transform_fns = list(spanning_borders(2), single_border(3, 3)))
final <- data.frame(
label = c(
"Overall", "Safety Analysis Set",
"Any Adverse event{\\super a}", "- Serious Adverse Event"
),
Drug_A = c("", "40", "10 (25%)", "0"),
Drug_B = c("", "40", "10 (25%)", "0"),
anbr = c(1, 2, 3, 4),
roworder = c(1, 1, 1, 1),
boldme = c(1, 0, 0, 0),
newrows = c(0, 0, 1, 0),
indentme = c(0, 0, 0, 1),
newpage = c(0, 0, 0, 0)
)
# Add spanning bottom borders under the cells in the first row
gentlg(
huxme = final,
wcol = c(0.70, 0.15, 0.15),
file = "TSFAEX",
colheader = c("", "Drug A", "Drug B"),
title = "This is Amazing Demonstration 1",
footers = c(
"Note: For demonstrative purposes only",
"{\\super a} Subjects are counted once for any given event."
),
border_fns = list(no_borders, spanning_borders(1))
)
# Tables with no bottom borders
gentlg(
huxme = final,
wcol = c(0.70, 0.15, 0.15),
file = "TSFAEX",
colheader = c("", "Drug A", "Drug B"),
title = "This is Amazing Demonstration 1",
footers = c(
"Note: For demonstrative purposes only",
"{\\super a} Subjects are counted once for any given event."
),
border_fns = list(no_borders)
)
# Tables with a border under cell in the 3nd row and 3rd column,
# and borders under cells in the first row
gentlg(
huxme = final,
wcol = c(0.70, 0.15, 0.15),
file = "TSFAEX",
colheader = c("", "Drug A", "Drug B"),
title = "This is Amazing Demonstration 1",
footers = c(
"Note: For demonstrative purposes only",
"{\\super a} Subjects are counted once for any given event."
),
border_fns = list(no_borders, spanning_borders(1), single_border(3, 3))
)
# We discourage, but you can pass the border matrix directly
mat <- matrix(rep(0, 8 * 3), ncol = 3, nrow = 8)
mat[3, 3] <- 1
gentlg(
huxme = final,
wcol = c(0.70, 0.15, 0.15),
file = "TSFAEX",
colheader = c("", "Drug A", "Drug B"),
title = "This is Amazing Demonstration 1",
footers = c(
"Note: For demonstrative purposes only",
"{\\super a} Subjects are counted once for any given event."
),
bottom_borders = mat, # The same as a single border under 3nd row and 3rd column
border_fns = list()
)
# clean up.
file.remove("tsfaex.rtf")
Run the code above in your browser using DataLab