Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
astra-cdc committed Jan 12, 2024
1 parent 812ff24 commit e9d8106
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 90 deletions.
45 changes: 22 additions & 23 deletions R/tab_subset.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ tab_subset = function(vr, vrby, lvls = c()
# Need to convert to factor for testing
if (is.logical(design$variables[,vr])) {
lbl = attr(design$variables[,vr], "label")
design$variables[,vr] %<>% factor
design$variables[,vr] %<>% droplevels %>% .fix_factor
design$variables[,vr] %<>% factor %>% droplevels %>% .fix_factor
attr(design$variables[,vr], "label") = lbl
}

Expand All @@ -96,27 +95,6 @@ tab_subset = function(vr, vrby, lvls = c()

ret = list()
if (is.logical(design$variables[,vr]) || is.factor(design$variables[,vr])) {
if (test) {
frm = as.formula(paste0("~ `", vr, "` + `", vrby, "`"))
fo = svychisq(frm, design, statistic = getOption("surveytable.svychisq_statistic"))
rT = data.frame(`p-value` = fo$p.value, check.names = FALSE)
test_name = fo$method
test_title = paste0("Association between "
, .getvarname(design, vr)
, " and ", .getvarname(design, vrby))
# do_pairs = if(test_pairs == "no") {
# FALSE
# } else if(test_pairs == "yes") {
# TRUE
# } else {
# rT$`p-value` <= alpha
# }

ret[[ test_name ]] = .test_table(rT = rT
, test_name = test_name, test_title = test_title, alpha = alpha
, screen = screen, csv = csv)
}

for (ii in lvl0) {
d1 = design[which(design$variables[,vrby] == ii),]
if(inherits(d1, "svyrep.design")) {
Expand All @@ -134,8 +112,29 @@ tab_subset = function(vr, vrby, lvls = c()
, screen = screen
, csv = csv)
}

# if (test && do_pairs) {
if (test) {
frm = as.formula(paste0("~ `", vr, "` + `", vrby, "`"))
fo = svychisq(frm, design, statistic = getOption("surveytable.svychisq_statistic"))
rT = data.frame(`p-value` = fo$p.value, check.names = FALSE)
test_name = fo$method
test_title = paste0("Association between "
, .getvarname(design, vr)
, " and ", .getvarname(design, vrby))
# do_pairs = if(test_pairs == "no") {
# FALSE
# } else if(test_pairs == "yes") {
# TRUE
# } else {
# rT$`p-value` <= alpha
# }

ret[[ test_name ]] = .test_table(rT = rT
, test_name = test_name, test_title = test_title, alpha = alpha
, screen = screen, csv = csv)

###
for (ii in lvl0 ) {
d1 = design[which(design$variables[,vrby] == ii),]
if(inherits(d1, "svyrep.design")) {
Expand Down
114 changes: 57 additions & 57 deletions docs/articles/surveytable.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pkgdown_sha: ~
articles:
Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables: Example-National-Ambulatory-Medical-Care-Survey-NAMCS-tables.html
surveytable: surveytable.html
last_built: 2024-01-11T20:49Z
last_built: 2024-01-12T03:31Z
urls:
reference: https://cdcgov.github.io/surveytable/reference
article: https://cdcgov.github.io/surveytable/articles
Expand Down
16 changes: 8 additions & 8 deletions docs/reference/tab_subset.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

0 comments on commit e9d8106

Please sign in to comment.