diff --git a/NEWS b/NEWS index be57332..6b05f03 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ BUG FIXES * Fix a missing value handling issue (via @chipmanj). Closes issue #26. +* mean (sd) was changed to mean (SD) to be consistent with + median [IQR]. + NEW FEATURES * Add a helper for exporting TableOne objects to Markdown diff --git a/R/modules-print.R b/R/modules-print.R index 60c287b..20588fd 100644 --- a/R/modules-print.R +++ b/R/modules-print.R @@ -276,7 +276,7 @@ ModuleContFormatStrata <- function(ContTable, nVars, listOfFunctions, digits) { } else { ## Apply row by row within each non-empty stratum - ## This row-by-row operation is necessary to handle mean (sd) and median [IQR] + ## This row-by-row operation is necessary to handle mean (SD) and median [IQR] out <- sapply(seq_len(nVars), FUN = function(i) { diff --git a/R/print.ContTable.R b/R/print.ContTable.R index d7e3c7d..ab923c4 100644 --- a/R/print.ContTable.R +++ b/R/print.ContTable.R @@ -7,7 +7,7 @@ ##' @param pDigits Number of digits to print for p-values (also used for standardized mean differences). ##' @param quote Whether to show everything in quotes. The default is FALSE. If TRUE, everything including the row and column names are quoted so that you can copy it to Excel easily. ##' @param missing Whether to show missing data information. -##' @param explain Whether to add explanation to the variable names, i.e., (mean (sd) or median [IQR]) is added to the variable names. +##' @param explain Whether to add explanation to the variable names, i.e., (mean (SD) or median [IQR]) is added to the variable names. ##' @param printToggle Whether to print the output. If FALSE, no output is created, and a matrix is invisibly returned. ##' @param noSpaces Whether to remove spaces added for alignment. Use this option if you prefer to align numbers yourself in other software. ##' @param nonnormal A character vector to specify the variables for which the p-values should be those of nonparametric tests. By default all p-values are from normal assumption-based tests (oneway.test). @@ -242,13 +242,13 @@ function(x, # ContTable object } - ## Add mean (sd) or median [IQR]/median [range] explanation if requested + ## Add mean (SD) or median [IQR]/median [range] explanation if requested if (explain) { ## Create a vector of explanations to be pasted if (minMax == FALSE) { - what <- c(" (mean (sd))"," (median [IQR])")[nonnormal] + what <- c(" (mean (SD))"," (median [IQR])")[nonnormal] } else if (minMax == TRUE) { - what <- c(" (mean (sd))"," (median [range])")[nonnormal] + what <- c(" (mean (SD))"," (median [range])")[nonnormal] } ## Paste to the rownames rownames(out) <- paste0(rownames(out), what) diff --git a/R/print.svyContTable.R b/R/print.svyContTable.R index 9978594..128e7a3 100644 --- a/R/print.svyContTable.R +++ b/R/print.svyContTable.R @@ -7,7 +7,7 @@ ##' @param pDigits Number of digits to print for p-values (also used for standardized mean differences). ##' @param quote Whether to show everything in quotes. The default is FALSE. If TRUE, everything including the row and column names are quoted so that you can copy it to Excel easily. ##' @param missing Whether to show missing data information. -##' @param explain Whether to add explanation to the variable names, i.e., (mean (sd) or median [IQR]) is added to the variable names. +##' @param explain Whether to add explanation to the variable names, i.e., (mean (SD) or median [IQR]) is added to the variable names. ##' @param printToggle Whether to print the output. If FALSE, no output is created, and a matrix is invisibly returned. ##' @param noSpaces Whether to remove spaces added for alignment. Use this option if you prefer to align numbers yourself in other software. ##' @param nonnormal A character vector to specify the variables for which the p-values should be those of nonparametric tests. By default all p-values are from normal assumption-based tests (oneway.test). @@ -188,13 +188,13 @@ function(x, # ContTable object } - ## Add mean (sd) or median [IQR]/median [range] explanation if requested + ## Add mean (SD) or median [IQR]/median [range] explanation if requested if (explain) { ## Create a vector of explanations to be pasted if (minMax == FALSE) { - what <- c(" (mean (sd))"," (median [IQR])")[nonnormal] + what <- c(" (mean (SD))"," (median [IQR])")[nonnormal] } else if (minMax == TRUE) { - what <- c(" (mean (sd))"," (median [range])")[nonnormal] + what <- c(" (mean (SD))"," (median [range])")[nonnormal] } ## Paste to the rownames rownames(out) <- paste0(rownames(out), what) diff --git a/README.md b/README.md index 6393bd8..91f91a0 100644 --- a/README.md +++ b/README.md @@ -44,30 +44,30 @@ In this table, continuous and categorical variables can be placed in any order. Stratified by trt 1 2 p test SMD n 158 154 -time (mean (sd)) 2015.62 (1094.12) 1996.86 (1155.93) 0.883 0.017 +time (mean (SD)) 2015.62 (1094.12) 1996.86 (1155.93) 0.883 0.017 status (%) 0.884 exact 0.054 0 83 (52.5) 85 (55.2) 1 10 ( 6.3) 9 ( 5.8) 2 65 (41.1) 60 (39.0) -trt (mean (sd)) 1.00 (0.00) 2.00 (0.00) <0.001 Inf -age (mean (sd)) 51.42 (11.01) 48.58 (9.96) 0.018 0.270 +trt (mean (SD)) 1.00 (0.00) 2.00 (0.00) <0.001 Inf +age (mean (SD)) 51.42 (11.01) 48.58 (9.96) 0.018 0.270 sex = f (%) 137 (86.7) 139 (90.3) 0.421 0.111 -ascites (mean (sd)) 0.09 (0.29) 0.06 (0.25) 0.434 0.089 -hepato (mean (sd)) 0.46 (0.50) 0.56 (0.50) 0.069 0.206 -spiders (mean (sd)) 0.28 (0.45) 0.29 (0.46) 0.886 0.016 +ascites (mean (SD)) 0.09 (0.29) 0.06 (0.25) 0.434 0.089 +hepato (mean (SD)) 0.46 (0.50) 0.56 (0.50) 0.069 0.206 +spiders (mean (SD)) 0.28 (0.45) 0.29 (0.46) 0.886 0.016 edema (%) 0.877 0.058 0 132 (83.5) 131 (85.1) 0.5 16 (10.1) 13 ( 8.4) 1 10 ( 6.3) 10 ( 6.5) bili (median [IQR]) 1.40 [0.80, 3.20] 1.30 [0.72, 3.60] 0.842 nonnorm 0.171 chol (median [IQR]) 315.50 [247.75, 417.00] 303.50 [254.25, 377.00] 0.544 nonnorm 0.038 -albumin (mean (sd)) 3.52 (0.44) 3.52 (0.40) 0.874 0.018 +albumin (mean (SD)) 3.52 (0.44) 3.52 (0.40) 0.874 0.018 copper (median [IQR]) 73.00 [40.00, 121.00] 73.00 [43.00, 139.00] 0.717 nonnorm <0.001 alk.phos (median [IQR]) 1214.50 [840.75, 2028.00] 1283.00 [922.50, 1949.75] 0.812 nonnorm 0.037 -ast (mean (sd)) 120.21 (54.52) 124.97 (58.93) 0.460 0.084 +ast (mean (SD)) 120.21 (54.52) 124.97 (58.93) 0.460 0.084 trig (median [IQR]) 106.00 [84.50, 146.00] 113.00 [84.50, 155.00] 0.370 nonnorm 0.017 -platelet (mean (sd)) 258.75 (100.32) 265.20 (90.73) 0.555 0.067 -protime (mean (sd)) 10.65 (0.85) 10.80 (1.14) 0.197 0.146 +platelet (mean (SD)) 258.75 (100.32) 265.20 (90.73) 0.555 0.067 +protime (mean (SD)) 10.65 (0.85) 10.80 (1.14) 0.197 0.146 stage (%) 0.205 exact 0.246 1 12 ( 7.6) 4 ( 2.6) 2 35 (22.2) 32 (20.8) diff --git a/man/print.ContTable.Rd b/man/print.ContTable.Rd index 0f33bd7..126b018 100644 --- a/man/print.ContTable.Rd +++ b/man/print.ContTable.Rd @@ -20,7 +20,7 @@ \item{missing}{Whether to show missing data information.} -\item{explain}{Whether to add explanation to the variable names, i.e., (mean (sd) or median [IQR]) is added to the variable names.} +\item{explain}{Whether to add explanation to the variable names, i.e., (mean (SD) or median [IQR]) is added to the variable names.} \item{printToggle}{Whether to print the output. If FALSE, no output is created, and a matrix is invisibly returned.} diff --git a/man/print.svyContTable.Rd b/man/print.svyContTable.Rd index a7ba8a3..b9eb1c7 100644 --- a/man/print.svyContTable.Rd +++ b/man/print.svyContTable.Rd @@ -20,7 +20,7 @@ \item{missing}{Whether to show missing data information.} -\item{explain}{Whether to add explanation to the variable names, i.e., (mean (sd) or median [IQR]) is added to the variable names.} +\item{explain}{Whether to add explanation to the variable names, i.e., (mean (SD) or median [IQR]) is added to the variable names.} \item{printToggle}{Whether to print the output. If FALSE, no output is created, and a matrix is invisibly returned.}