test_that("footnote structure",{
# force list if entered as vector
tfrmt<-tfrmt(
# specify columns in the data
group = c(rowlbl1),
label = rowlbl2,
column = c(col2,trt),
param = param,
value = value,
# set formatting for values
body_plan = body_plan(
frmt_structure(group_val = ".default", label_val = ".default", frmt_combine("{n} {pct}",
n = frmt("xxx"),
pct = frmt_when("==100" ~ "",
"==0" ~ "",
TRUE ~ frmt("(xx.x %)"))))),
# Specify row group plan
# Indent the rowlbl2
row_grp_plan = row_grp_plan(
row_grp_structure(group_val = ".default", element_block(post_space = " ")),
label_loc = element_row_grp_loc(location = "column")),
footnote_plan = footnote_plan(
footnote_structure("Test footnote 2",column_val=c(trt="Placebo")),
marks="letters"
)
)
expect_equal(is.list(tfrmt$footnote_plan$struct_list[[1]]$column_val),TRUE)
tfrmt2<-tfrmt(
# specify columns in the data
group = c(rowlbl0,rowlbl1),
label = rowlbl2,
column = c(col2,trt),
param = param,
value = value,
# set formatting for values
body_plan = body_plan(
frmt_structure(group_val = ".default", label_val = ".default", frmt_combine("{n} {pct}",
n = frmt("xxx"),
pct = frmt_when("==100" ~ "",
"==0" ~ "",
TRUE ~ frmt("(xx.x %)"))))),
# Specify row group plan
# Indent the rowlbl2
row_grp_plan = row_grp_plan(
row_grp_structure(group_val = ".default", element_block(post_space = " ")),
label_loc = element_row_grp_loc(location = "column")),
footnote_plan = footnote_plan(
footnote_structure("Test footnote 2",group_val=c(rowlbl1="Completion Status")),
marks="letters"
)
)
expect_equal(is.list(tfrmt2$footnote_plan$struct_list[[1]]$group_val),TRUE)
expect_error(tfrmt(
# specify columns in the data
group = c(rowlbl1),
label = rowlbl2,
column = c(col2,trt),
param = param,
value = value,
# set formatting for values
body_plan = body_plan(
frmt_structure(group_val = ".default", label_val = ".default", frmt_combine("{n} {pct}",
n = frmt("xxx"),
pct = frmt_when("==100" ~ "",
"==0" ~ "",
TRUE ~ frmt("(xx.x %)"))))),
# Specify row group plan
# Indent the rowlbl2
row_grp_plan = row_grp_plan(
row_grp_structure(group_val = ".default", element_block(post_space = " ")),
label_loc = element_row_grp_loc(location = "column")),
footnote_plan = footnote_plan(
footnote_structure("Test footnote 2",column_val=list("Treatment column","Placebo")),
marks="letters"
)
) , "when column_val is a list, must be a named list")
expect_error(tfrmt(
# specify columns in the data
group = c(rowlbl1),
label = rowlbl2,
column = c(col2,trt),
param = param,
value = value,
# set formatting for values
body_plan = body_plan(
frmt_structure(group_val = ".default", label_val = ".default", frmt_combine("{n} {pct}",
n = frmt("xxx"),
pct = frmt_when("==100" ~ "",
"==0" ~ "",
TRUE ~ frmt("(xx.x %)"))))),
# Specify row group plan
# Indent the rowlbl2
row_grp_plan = row_grp_plan(
row_grp_structure(group_val = ".default", element_block(post_space = " ")),
label_loc = element_row_grp_loc(location = "column")),
footnote_plan = footnote_plan(
footnote_structure("Test footnote 2",column_val=list("Treatment column",trt="Placebo")),
marks="letters"
)
) , "when column_val is a list, each entry must be named")
expect_error(tfrmt(
# specify columns in the data
group = c(rowlbl0,rowlbl1),
label = rowlbl2,
column = c(col2,trt),
param = param,
value = value,
# set formatting for values
body_plan = body_plan(
frmt_structure(group_val = ".default", label_val = ".default", frmt_combine("{n} {pct}",
n = frmt("xxx"),
pct = frmt_when("==100" ~ "",
"==0" ~ "",
TRUE ~ frmt("(xx.x %)"))))),
# Specify row group plan
# Indent the rowlbl2
row_grp_plan = row_grp_plan(
row_grp_structure(group_val = ".default", element_block(post_space = " ")),
label_loc = element_row_grp_loc(location = "column")),
footnote_plan = footnote_plan(
footnote_structure("Test footnote 2",group_val=c("Group","Completion Status")),
marks="letters"
)
), "when tfrmt contains multiple groups, group_val must be a named list")
expect_error(tfrmt(
# specify columns in the data
group = c(rowlbl0,rowlbl1),
label = rowlbl2,
column = c(col2,trt),
param = param,
value = value,
# set formatting for values
body_plan = body_plan(
frmt_structure(group_val = ".default", label_val = ".default", frmt_combine("{n} {pct}",
n = frmt("xxx"),
pct = frmt_when("==100" ~ "",
"==0" ~ "",
TRUE ~ frmt("(xx.x %)"))))),
# Specify row group plan
# Indent the rowlbl2
row_grp_plan = row_grp_plan(
row_grp_structure(group_val = ".default", element_block(post_space = " ")),
label_loc = element_row_grp_loc(location = "column")),
footnote_plan = footnote_plan(
footnote_structure("Test footnote 2",group_val=c("Group",rowlbl1="Completion Status")),
marks="letters"
)
), "when group_val is a list, each entry must be named")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.