Skip to content

Variable Stub Nesting #373

@dbosak01

Description

@dbosak01

User wants to create a stub with some sections nested and some not:

library(tidyverse)
library(sassy)

df <- read.table(header = TRUE, text = '
var label A B
"A" "Some text 1" "11" "8"
"A" "Some text 2" "10" "7"
"RACE" " White" "6 (54.5)" "4 (50.0)"
"RACE" " Black" "4 (36.4)" "3 (37.5)"
"RACE" " Others" "1 (9.1)" "1 (12.5)"
"B" "Some text 3" "6 (54.5)" "4 (50.0)"
"B" "Some text 4" "4 (36.4)" "3 (37.5)"
')

var_fmt <- c(A = "", RACE = "Race - n (%)", B = "")

pth <- "I:/duong"

tbl <- create_table(df, first_row_blank = TRUE, borders = c("top", "bottom")) %>%
titles("Table 1.0 Demographics", font_size = 10) %>%
stub(vars = c("var", "label"), "", width = 2.5) %>%
define(var, blank_after = TRUE, format = var_fmt, label_row = TRUE) %>%
define(A, align = "center", width=1.2, label = "Placebo", n=11) %>%
define(B, align = "center", width=1.2, label = "Drug", n=8)

rpt <- create_report(file.path(pth, "t_demo1.rtf"), output_type = "RTF", font = "Arial") %>%
add_content(tbl)

write_report(rpt)

file.show("I:/duong/t_demo1.rtf")

View report

file.show(res$modified_path)

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions