Skip to content

Commit

Permalink
Change mean (sd) to mean (SD)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaz-yos committed Feb 16, 2019
1 parent a67aa5f commit 359353a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 21 deletions.
3 changes: 3 additions & 0 deletions NEWS
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/modules-print.R
Expand Up @@ -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) {

Expand Down
8 changes: 4 additions & 4 deletions R/print.ContTable.R
Expand Up @@ -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).
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions R/print.svyContTable.R
Expand Up @@ -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).
Expand Down Expand Up @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions README.md
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion man/print.ContTable.Rd

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

2 changes: 1 addition & 1 deletion man/print.svyContTable.Rd

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

0 comments on commit 359353a

Please sign in to comment.