Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jinseob2kim/jstable
Browse files Browse the repository at this point in the history
  • Loading branch information
jinseob2kim committed Nov 26, 2023
2 parents d1aae84 + 4939f98 commit dc852db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
13 changes: 6 additions & 7 deletions R/CreateTableOneJS.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ CreateTableOne2 <- function(data, strata, vars, factorVars, includeNA = F, test

if (Labels & !is.null(labeldata)) {
colname.group_var <- unlist(labeldata[.(strata, names(res$CatTable)), val_label])
if (is.na(colname.group_var[1])){
if (is.na(colname.group_var[1])) {
colname.group_var[1] <- "Overall"
}
if (showAllLevels == T) {
Expand Down Expand Up @@ -284,7 +284,7 @@ CreateTableOneJS <- function(vars, strata = NULL, strata2 = NULL, data, factorVa
testNormal = testNormal, argsNormal = argsNormal,
testNonNormal = testNonNormal, argsNonNormal = argsNonNormal, smd = smd,
showAllLevels = showAllLevels, printToggle = printToggle, quote = quote, Labels = F, nonnormal = nonnormal, exact = exact,
catDigits = catDigits, contDigits = contDigits, pDigits = pDigits, minMax = minMax, showpm = T, addOverall =F
catDigits = catDigits, contDigits = contDigits, pDigits = pDigits, minMax = minMax, showpm = T, addOverall = F
)

if (showAllLevels == T) {
Expand Down Expand Up @@ -406,18 +406,17 @@ CreateTableOneJS <- function(vars, strata = NULL, strata2 = NULL, data, factorVa
colname.group_var <- val_combination[, paste(V1, ":", V2, sep = "")]
colname.group_index <- paste(labeldata[variable == strata, var_label][1], ":", labeldata[variable == strata2, var_label][1], sep = "")
if (showAllLevels == T) {
if (addOverall){
if (addOverall) {
colnames(ptb1)[1:(length(colname.group_var) + 2)] <- c(colname.group_index, "Overall", colname.group_var)
} else{
} else {
colnames(ptb1)[1:(length(colname.group_var) + 1)] <- c(colname.group_index, colname.group_var)
}
} else {
if (addOverall){
if (addOverall) {
colnames(ptb1)[1:length(colname.group_var) + 1] <- colname.group_var
} else{
} else {
colnames(ptb1)[1:length(colname.group_var)] <- colname.group_var
}

}

# caption
Expand Down
10 changes: 5 additions & 5 deletions R/svyCreateTableOneJS.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ svyCreateTableOne2 <- function(data, strata, vars, factorVars, includeNA = F, te

if (Labels & !is.null(labeldata)) {
colname.group_var <- unlist(labeldata[get("variable") == strata, "val_label"])
if (is.na(colname.group_var[1])){
if (is.na(colname.group_var[1])) {
colname.group_var[1] <- "Overall"
}
if (showAllLevels == T) {
Expand Down Expand Up @@ -356,15 +356,15 @@ svyCreateTableOneJS <- function(vars, strata = NULL, strata2 = NULL, data, facto
colname.group_var <- val_combination[, paste(V1, ":", V2, sep = "")]
colname.group_index <- paste(labeldata[variable == strata, var_label][1], ":", labeldata[variable == strata2, var_label][1], sep = "")
if (showAllLevels == T) {
if (addOverall){
if (addOverall) {
colnames(ptb1)[1:(length(colname.group_var) + 2)] <- c(colname.group_index, "Overall", colname.group_var)
} else{
} else {
colnames(ptb1)[1:(length(colname.group_var) + 1)] <- c(colname.group_index, colname.group_var)
}
} else {
if (addOverall){
if (addOverall) {
colnames(ptb1)[1:length(colname.group_var) + 1] <- colname.group_var
} else{
} else {
colnames(ptb1)[1:length(colname.group_var)] <- colname.group_var
}
}
Expand Down

0 comments on commit dc852db

Please sign in to comment.