From b3100098d86f8e0b45952038a4f1b20fbe8c74d0 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Fri, 16 Jun 2017 10:59:05 -0400 Subject: [PATCH 01/44] Revert README.md to develop version --- README.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 82dbabe..59af7cb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -tableone (release repo) +tableone (developmental repo) =============================================================================== -[![Travis-CI Build Status](https://travis-ci.org/kaz-yos/tableone.svg?branch=master)](https://travis-ci.org/kaz-yos/tableone) +[![Travis-CI Build Status](https://travis-ci.org/kaz-yos/tableone.svg?branch=develop)](https://travis-ci.org/kaz-yos/tableone) **An R package to create "Table 1", description of baseline characteristics** @@ -80,10 +80,21 @@ stage (%) 0.2 Installation ------------------------------------------------------------------------------- -This is the release version of the tableone package either to be released on CRAN or is already on CRAN. The installation can be done by the usual package installation via CRAN. +This version of tableone package for R is developmetal, and may not be available from the CRAN. You can install it using one of the following way. -- https://cran.r-project.org/package=tableone +**Direct installation from github** -If you prefer to follow the latest development, please see the developmetal repo: +You first need to install the devtools package to do the following. You can choose from the latest stable version and the latest development version. -- https://github.com/kaz-yos/tableone/tree/develop +``` + +## Install devtools (if you do not have it already) +> install.packages("devtools") +## Install directly from github (develop branch) +> devtools::install_github(repo = "kaz-yos/tableone", ref = "develop") + +``` + +Using devtools may requires some preparation, please see the following link for information. + +http://www.rstudio.com/projects/devtools/ From 5b238eaa65d8b5fbaaef831f078baf14dbcdb5f5 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Thu, 31 Aug 2017 11:11:31 -0400 Subject: [PATCH 02/44] Handle labelled class as categorical --- R/CreateTableOne.R | 2 +- R/svyCreateTableOne.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/CreateTableOne.R b/R/CreateTableOne.R index 97ed3b9..e6923fe 100644 --- a/R/CreateTableOne.R +++ b/R/CreateTableOne.R @@ -149,7 +149,7 @@ function(vars, # character vector of variab ## Classify as varFactors if any one of these classes are contained varFactors <-sapply(varClasses, function(VEC) { - any(VEC %in% c("factor", "ordered", "logical", "character")) + any(VEC %in% c("factor", "ordered", "logical", "character", "labelled")) }) varFactors <- names(varFactors)[varFactors] diff --git a/R/svyCreateTableOne.R b/R/svyCreateTableOne.R index 28af559..91cc542 100644 --- a/R/svyCreateTableOne.R +++ b/R/svyCreateTableOne.R @@ -123,7 +123,7 @@ function(vars, # character vector of variable ## Classify as varFactors if any one of these classes are contained varFactors <- sapply(varClasses, function(VEC) { - any(VEC %in% c("factor", "ordered", "logical", "character")) + any(VEC %in% c("factor", "ordered", "logical", "character", "labelled")) }) varFactors <- names(varFactors)[varFactors] From 24187debebf21cb07373cd4b6f442b0cca69dad7 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Thu, 31 Aug 2017 11:15:45 -0400 Subject: [PATCH 03/44] Comment on 0.8.1 --- DESCRIPTION | 4 ++-- NEWS | 8 ++++++++ cran-comment.md | 9 +++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e124018..23a90e3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: tableone Type: Package Title: Create 'Table 1' to Describe Baseline Characteristics -Version: 0.8.1 -Date: 2017-06-16 +Version: 0.8.2 +Date: 2017-08-31 Author: Kazuki Yoshida, Justin Bohn. Maintainer: Kazuki Yoshida Description: Creates 'Table 1', i.e., description of baseline patient diff --git a/NEWS b/NEWS index 0daf499..c3d75bf 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +tableone 0.8.2 (2017-08-31) +---------------------------------------------------------------- + +BUG FIXES + +* Handle labelled class as categorical. + + tableone 0.8.1 (2017-06-17) ---------------------------------------------------------------- diff --git a/cran-comment.md b/cran-comment.md index 9b0d5c5..a7d824a 100644 --- a/cran-comment.md +++ b/cran-comment.md @@ -1,17 +1,14 @@ ## What's new The following changes are included. -tableone 0.8.1 (2017-06-17) +tableone 0.8.2 (2017-08-31) ---------------------------------------------------------------- BUG FIX -* Fix alignment issue with the Missing column. Note currently the - percentage is shown with 1 decimal and this is hard-coded. -* Change vignetteBuilder to knitr to form the index correctly. -* Single-quote package names in DESCRIPTION. +* Handle labelled class as categorical. ## Test environments -* Local OS X 10.12.5, R 3.4.0 +* Local OS X 10.12.6, R 3.4.1 * Ubuntu Linux on Travis-CI (oldrel, release, and devel) * win-builder (release and devel) From d90a7f5a1ce44046f2865b12140531be24bd347d Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 25 Oct 2017 16:03:07 -0400 Subject: [PATCH 04/44] Update version --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 23a90e3..2a9727f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: tableone Type: Package Title: Create 'Table 1' to Describe Baseline Characteristics -Version: 0.8.2 -Date: 2017-08-31 +Version: 0.9.0 +Date: 2017-10-25 Author: Kazuki Yoshida, Justin Bohn. Maintainer: Kazuki Yoshida Description: Creates 'Table 1', i.e., description of baseline patient From 25a61773b86553d555480280ad31a0d0cae47946 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 25 Oct 2017 16:03:36 -0400 Subject: [PATCH 05/44] Previous test results --- cran-check.txt | 4 ++-- tableone.Rcheck/tableone-Ex.Rout | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cran-check.txt b/cran-check.txt index 58d77f9..64afa5c 100644 --- a/cran-check.txt +++ b/cran-check.txt @@ -1,11 +1,11 @@ * using log directory ‘/Users/kazuki/Documents/programming/r/tableone/tableone.Rcheck’ -* using R version 3.4.0 (2017-04-21) +* using R version 3.4.1 (2017-06-30) * using platform: x86_64-apple-darwin15.6.0 (64-bit) * using session charset: UTF-8 * using option ‘--as-cran’ * checking for file ‘tableone/DESCRIPTION’ ... OK * checking extension type ... Package -* this is package ‘tableone’ version ‘0.8.1’ +* this is package ‘tableone’ version ‘0.8.2’ * checking CRAN incoming feasibility ... Note_to_CRAN_maintainers Maintainer: ‘Kazuki Yoshida ’ * checking package namespace information ... OK diff --git a/tableone.Rcheck/tableone-Ex.Rout b/tableone.Rcheck/tableone-Ex.Rout index d53cdb1..19e2458 100644 --- a/tableone.Rcheck/tableone-Ex.Rout +++ b/tableone.Rcheck/tableone-Ex.Rout @@ -1,5 +1,5 @@ -R version 3.4.0 (2017-04-21) -- "You Stupid Darkness" +R version 3.4.1 (2017-06-30) -- "Single Candle" Copyright (C) 2017 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin15.6.0 (64-bit) @@ -3316,7 +3316,7 @@ detaching ‘package:survey’, ‘package:survival’, ‘package:Matrix’, > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 9.407 0.276 9.755 0.006 0.005 +Time elapsed: 6.262 0.206 6.628 0.004 0.003 > grDevices::dev.off() null device 1 From 1f23e8f6602ecb32e366639b62443b13a83c23ff Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 25 Oct 2017 16:03:48 -0400 Subject: [PATCH 06/44] Keep variable labels (list) in MetaData --- R/CreateTableOne.R | 7 ++++++- R/svyCreateTableOne.R | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/R/CreateTableOne.R b/R/CreateTableOne.R index e6923fe..579b1de 100644 --- a/R/CreateTableOne.R +++ b/R/CreateTableOne.R @@ -144,6 +144,9 @@ function(vars, # character vector of variab ## Get the missing percentage for each variable (no strata). percentMissing <- ModulePercentMissing(data[vars]) + ## Get variable labels (list) + varLabels <- labelled::var_label(data[vars]) + ## Get the classes of the variables varClasses <- lapply(data[vars], class) @@ -243,7 +246,9 @@ function(vars, # character vector of variab varFactors = varFactors, varNumerics = varNumerics, ## Missing data percentage for each variable (no strata). - percentMissing = percentMissing)) + percentMissing = percentMissing, + ## Variable labels + varLabels = varLabels)) ## Give a class class(TableOneObject) <- "TableOne" diff --git a/R/svyCreateTableOne.R b/R/svyCreateTableOne.R index 91cc542..53d40b3 100644 --- a/R/svyCreateTableOne.R +++ b/R/svyCreateTableOne.R @@ -118,6 +118,9 @@ function(vars, # character vector of variable ## Get the missing percentage for each variable (no strata). percentMissing <- ModulePercentMissing(data$variables[vars]) + ## Get variable labels (list) + varLabels <- labelled::var_label(data$variables[vars]) + ## Get the classes of the variables varClasses <- lapply(data$variables[vars], class) @@ -215,7 +218,9 @@ function(vars, # character vector of variable varFactors = varFactors, varNumerics = varNumerics, ## Missing data percentage for each variable (no strata). - percentMissing = percentMissing)) + percentMissing = percentMissing, + ## Variable labels + varLabels = varLabels)) ## Give a class class(TableOneObject) <- c("svyTableOne", "TableOne") From d7f530a74689a2b8cfe6494fc1049c3ad5c043d1 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sat, 28 Oct 2017 14:41:22 -0400 Subject: [PATCH 07/44] Import labelled --- DESCRIPTION | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2a9727f..abfa0f5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,7 +20,8 @@ Imports: e1071, zoo, gmodels, - nlme + nlme, + labelled Suggests: survival, testthat, From 6febddad72c4d9145335302d2791a575c7317f29 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sat, 28 Oct 2017 14:49:17 -0400 Subject: [PATCH 08/44] Explain what is returned by var_label(df) (named list) labelled::var_label(df) will return a named list of strings and NULL. Each element is named by the corresponding variable name. The single string is the variable label if present. If no label exists for the variable, NULL is held. Therefore, it is a list rather than a vector. --- R/CreateTableOne.R | 2 +- R/svyCreateTableOne.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/CreateTableOne.R b/R/CreateTableOne.R index 579b1de..0fb4e55 100644 --- a/R/CreateTableOne.R +++ b/R/CreateTableOne.R @@ -144,7 +144,7 @@ function(vars, # character vector of variab ## Get the missing percentage for each variable (no strata). percentMissing <- ModulePercentMissing(data[vars]) - ## Get variable labels (list) + ## Get variable labels (named list of label string or NULL) varLabels <- labelled::var_label(data[vars]) ## Get the classes of the variables diff --git a/R/svyCreateTableOne.R b/R/svyCreateTableOne.R index 53d40b3..79a616c 100644 --- a/R/svyCreateTableOne.R +++ b/R/svyCreateTableOne.R @@ -118,7 +118,7 @@ function(vars, # character vector of variable ## Get the missing percentage for each variable (no strata). percentMissing <- ModulePercentMissing(data$variables[vars]) - ## Get variable labels (list) + ## Get variable labels (named list of label string or NULL) varLabels <- labelled::var_label(data$variables[vars]) ## Get the classes of the variables From 027c876d03789713ba193fd1402850e7551ed70f Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sat, 28 Oct 2017 15:20:14 -0400 Subject: [PATCH 09/44] Add dropEqual option (old tests passing) Add the dropEqual argument and use for each one of the following functions shown in the call sequence. ModuleCatFormatVariables() ModuleCatFormatStrata() print.CatTable() print.svyCatTable() ModuleFormatTables() print.TableOne() --- R/modules-print.R | 17 +++++++++++------ R/print.CatTable.R | 3 +++ R/print.TableOne.R | 3 +++ R/print.svyCatTable.R | 3 +++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/R/modules-print.R b/R/modules-print.R index f30a8ad..60c287b 100644 --- a/R/modules-print.R +++ b/R/modules-print.R @@ -322,7 +322,7 @@ ModuleContFormatStrata <- function(ContTable, nVars, listOfFunctions, digits) { ################################################################################ ## Module to loop over variables within a stratum formatting categorical variables -ModuleCatFormatVariables <- function(lstVars, varsToFormat, fmt, level, cramVars, showAllLevels) { +ModuleCatFormatVariables <- function(lstVars, varsToFormat, fmt, level, cramVars, dropEqual, showAllLevels) { ## Loop over variables within a stratum ## Each list element is a data frame summarizing levels @@ -378,9 +378,12 @@ ModuleCatFormatVariables <- function(lstVars, varsToFormat, fmt, level, cramVars DF[1,"crammedRowInd"] <- "crammed" } else { - ## Otherwise, keep the second level only - ## change variable name, and delete the first level. - DF$var <- sprintf("%s = %s", DF$var, DF$level) + ## Otherwise, keep the second level only. + ## Change variable name if dropEqual = FALSE. + if (!dropEqual) { + DF$var <- sprintf("%s = %s", DF$var, DF$level) + } + ## Delete the first level. DF <- DF[-1, , drop = FALSE] } @@ -412,7 +415,7 @@ ModuleCatFormatVariables <- function(lstVars, varsToFormat, fmt, level, cramVars ## Module to loop over strata formatting categorical variables -ModuleCatFormatStrata <- function(CatTable, digits, varsToFormat, cramVars, showAllLevels) { +ModuleCatFormatStrata <- function(CatTable, digits, varsToFormat, cramVars, dropEqual, showAllLevels) { ## Create format for percent used in the loop fmt1 <- paste0("%.", digits, "f") @@ -433,6 +436,7 @@ ModuleCatFormatStrata <- function(CatTable, digits, varsToFormat, cramVars, show varsToFormat = varsToFormat, fmt = fmt1, cramVars = cramVars, + dropEqual = dropEqual, showAllLevels = showAllLevels) @@ -632,7 +636,7 @@ ModuleFormatTables <- function(x, catDigits, contDigits, explain, pDigits, ## print.CatTable arguments passed format, exact, - showAllLevels, cramVars, + showAllLevels, cramVars, dropEqual, ## print.ContTable arguments passed nonnormal, minMax, insertLevel ) { @@ -680,6 +684,7 @@ ModuleFormatTables <- function(x, catDigits, contDigits, format = format, exact = exact, showAllLevels = showAllLevels, # Returns one more column if TRUE cramVars = cramVars, + dropEqual = dropEqual, ## print.ContTable arguments passed nonnormal = nonnormal, minMax = minMax, insertLevel = showAllLevels diff --git a/R/print.CatTable.R b/R/print.CatTable.R index 6245fb6..e98e878 100644 --- a/R/print.CatTable.R +++ b/R/print.CatTable.R @@ -13,6 +13,7 @@ ##' @param format The default is "fp" frequency (percentage). You can also choose from "f" frequency only, "p" percentage only, and "pf" percentage (frequency). ##' @param showAllLevels Whether to show all levels. FALSE by default, i.e., for 2-level categorical variables, only the higher level is shown to avoid redundant information. ##' @param cramVars A character vector to specify the two-level categorical variables, for which both levels should be shown in one row. +##' @param dropEqual Whether to drop " = second level name" description indicating which level is shown for two-level categorical variables. ##' @param test Whether to show p-values. TRUE by default. If FALSE, only the numerical summaries are shown. ##' @param exact A character vector to specify the variables for which the p-values should be those of exact tests. By default all p-values are from large sample approximation tests (chisq.test). ##' @param smd Whether to show standardized mean differences. FALSE by default. If there are more than one contrasts, the average of all possible standardized mean differences is shown. For individual contrasts, use \code{summary}. @@ -95,6 +96,7 @@ function(x, # CatTable object format = c("fp","f","p","pf")[1], # Format f_requency and/or p_ercent showAllLevels = FALSE, cramVars = NULL, # variables to be crammed into one row + dropEqual = FALSE, # Do not show " = second level" for two-level variables test = TRUE, # Whether to add p-values exact = NULL, # Which variables should be tested with exact tests @@ -163,6 +165,7 @@ function(x, # CatTable object digits = digits, varsToFormat = varsToFormat, cramVars = cramVars, + dropEqual = dropEqual, showAllLevels = showAllLevels) diff --git a/R/print.TableOne.R b/R/print.TableOne.R index 3901e73..ee4b3b5 100644 --- a/R/print.TableOne.R +++ b/R/print.TableOne.R @@ -17,6 +17,7 @@ ##' @param format The default is "fp" frequency (percentage). You can also choose from "f" frequency only, "p" percentage only, and "pf" percentage (frequency). ##' @param showAllLevels Whether to show all levels. FALSE by default, i.e., for 2-level categorical variables, only the higher level is shown to avoid redundant information. ##' @param cramVars A character vector to specify the two-level categorical variables, for which both levels should be shown in one row. +##' @param dropEqual Whether to drop " = second level name" description indicating which level is shown for two-level categorical variables. ##' @param exact A character vector to specify the variables for which the p-values should be those of exact tests. By default all p-values are from large sample approximation tests (chisq.test). ##' @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). ##' @param minMax Whether to use [min,max] instead of [p25,p75] for nonnormal variables. The default is FALSE. @@ -48,6 +49,7 @@ function(x, # TableOne object format = c("fp","f","p","pf")[1], # Format f_requency and/or p_ercent showAllLevels = FALSE, # Show all levels of a categorical variable cramVars = NULL, # Which 2-level variables to show both levels in one row + dropEqual = FALSE, # Do not show " = second level" for two-level variables exact = NULL, # Which variables should be tested with exact tests ## Continuous options @@ -67,6 +69,7 @@ function(x, # TableOne object ## Returns one more column if TRUE showAllLevels = showAllLevels, cramVars = cramVars, + dropEqual = dropEqual, ## print.ContTable arguments passed nonnormal = nonnormal, minMax = minMax, diff --git a/R/print.svyCatTable.R b/R/print.svyCatTable.R index 2c064d3..9eedcd3 100644 --- a/R/print.svyCatTable.R +++ b/R/print.svyCatTable.R @@ -13,6 +13,7 @@ ##' @param format The default is "fp" frequency (percentage). You can also choose from "f" frequency only, "p" percentage only, and "pf" percentage (frequency). ##' @param showAllLevels Whether to show all levels. FALSE by default, i.e., for 2-level categorical variables, only the higher level is shown to avoid redundant information. ##' @param cramVars A character vector to specify the two-level categorical variables, for which both levels should be shown in one row. +##' @param dropEqual Whether to drop " = second level name" description indicating which level is shown for two-level categorical variables. ##' @param test Whether to show p-values. TRUE by default. If FALSE, only the numerical summaries are shown. ##' @param exact This option is not available for tables from weighted data. ##' @param smd Whether to show standardized mean differences. FALSE by default. If there are more than one contrasts, the average of all possible standardized mean differences is shown. For individual contrasts, use \code{summary}. @@ -40,6 +41,7 @@ function(x, # CatTable object format = c("fp","f","p","pf")[1], # Format f_requency and/or p_ercent showAllLevels = FALSE, cramVars = NULL, # variables to be crammed into one row + dropEqual = FALSE, # Do not show " = second level" for two-level variables test = TRUE, # Whether to add p-values exact = NULL, # Which variables should be tested with exact tests @@ -109,6 +111,7 @@ function(x, # CatTable object digits = digits, varsToFormat = varsToFormat, cramVars = cramVars, + dropEqual = dropEqual, showAllLevels = showAllLevels) From e316e37ab87de0dba3baf0929d124215b82f02cd Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sat, 28 Oct 2017 15:37:33 -0400 Subject: [PATCH 10/44] Add tests for dropEqual option --- tests/testthat/test-CreateTableOne.R | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/testthat/test-CreateTableOne.R b/tests/testthat/test-CreateTableOne.R index 7184c0c..c4a3792 100644 --- a/tests/testthat/test-CreateTableOne.R +++ b/tests/testthat/test-CreateTableOne.R @@ -218,6 +218,28 @@ test_that("Missing percentages are correctly stored and printed", { }) +test_that("dropEqual options correctly retail two-level categorical variable names", { + + ## Default table matrix + mat_default <- print(pbcOverall) + mat_modified <- mat_default + ## Drop " = 1" etc by regex + rownames(mat_modified) <- gsub(" = .* \\(", " (", rownames(mat_modified)) + + ## dropEqual = TRUE to avoid creation of " = 1" + mat_dropEqual <- print(pbcOverall, dropEqual = TRUE) + + ## Expectations + ## These must differ. + expect_false(identical(mat_default, mat_modified)) + expect_false(identical(rownames(mat_default), rownames(mat_modified))) + expect_false(all(rownames(mat_default) == rownames(mat_modified))) + ## These must match. + expect_equal(rownames(mat_modified), rownames(mat_dropEqual)) + expect_equal(mat_modified, mat_dropEqual) +}) + + test_that("printing of a TableOne object does not regress", { ## Expectations From a5f0369aa7084988271283837156d3eb1c87a6ca Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sat, 28 Oct 2017 15:41:51 -0400 Subject: [PATCH 11/44] Explain dropEqual in NEWS --- NEWS | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/NEWS b/NEWS index c3d75bf..233aeb8 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,15 @@ +tableone 0.9.0 (2017-10-28) +---------------------------------------------------------------- + +NEW FEATURES + +* The "dropEqual" option for the print methods was implemented. If + TRUE, the level description for two-level variables such as " = 1" + and " = TRUE" are not shown. This can obscure what level is being + shown depending on the variable naming scheme, thus, should only + be used after the initial results were checked for correctness. + + tableone 0.8.2 (2017-08-31) ---------------------------------------------------------------- From 5d62760467ebe24be06ad132cba980f957663c05 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sat, 28 Oct 2017 16:08:41 -0400 Subject: [PATCH 12/44] Add varLabels option to print.TableOne Basic string replacement of variable names with the corresponding variable label where available at the time when the table is in its intermediate form of a list of string matrices. --- R/print.TableOne.R | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/R/print.TableOne.R b/R/print.TableOne.R index ee4b3b5..1068bcd 100644 --- a/R/print.TableOne.R +++ b/R/print.TableOne.R @@ -14,6 +14,7 @@ ##' @param smd Whether to show standardized mean differences. FALSE by default. If there are more than one contrasts, the average of all possible standardized mean differences is shown. For individual contrasts, use \code{summary}. ##' @param noSpaces Whether to remove spaces added for alignment. Use this option if you prefer to align numbers yourself in other software. ##' @param padColnames Whether to pad column names with spaces to center justify. The default is FALSE. It is not conducted if noSpaces = TRUE. +##' @param varLabels Whether to replace variable names with variable labels obtained from \code{labelled::var_label()} function. ##' @param format The default is "fp" frequency (percentage). You can also choose from "f" frequency only, "p" percentage only, and "pf" percentage (frequency). ##' @param showAllLevels Whether to show all levels. FALSE by default, i.e., for 2-level categorical variables, only the higher level is shown to avoid redundant information. ##' @param cramVars A character vector to specify the two-level categorical variables, for which both levels should be shown in one row. @@ -44,6 +45,7 @@ function(x, # TableOne object smd = FALSE, # Whether to add standardized mean differences noSpaces = FALSE, # Whether to remove spaces for alignments padColnames = FALSE, # Whether to pad column names for alignments + varLabels = FALSE, # Whether to show variable labels instead of names. ## Categorical options format = c("fp","f","p","pf")[1], # Format f_requency and/or p_ercent @@ -94,10 +96,32 @@ function(x, # TableOne object spcFmtEltTables <- ModuleAddSpacesToTable(FmtElementTables, nSpacesToAdd, showAllLevels) - ## Create a list of one variable tables excluding sample size row + ## Create a list of one variable tables excluding sample size row. + ## This is based on the variable order in the MetaData. lstOneVarTables <- ModuleListOfOneVarTables(spcFmtEltTables, MetaData = x$MetaData) + ## Replace variable names with variable labels if requested. + ## Loop over the variable replacing its name with its label. + if (varLabels) { + lstOneVarTables <- + lapply(seq_along(lstOneVarTables), + function(i) { + ## Each element is a string matrix. + mat <- lstOneVarTables[[i]] + ## Manipulate if a non-NULL label is available. + ## Note MetaData$varLabels is a list. + if (!is.null(x$MetaData$varLabels[[i]])) { + ## The first row name contains the variable name + ## without preceding space. Replace by exact matching. + rownames(mat)[1] <- gsub(paste0("^", x$MetaData$vars[i]), + x$MetaData$varLabels[[i]], + rownames(mat)[1]) + } + ## Return the entire matrix. + mat + }) + } ## Check if the first row is CatTable element ## if so, pick sample size row from space-padded CatTable element From 24b957376ffa1cec3f38cbf3b1a32945eab727dc Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sat, 28 Oct 2017 16:13:32 -0400 Subject: [PATCH 13/44] Clean main test file --- tests/testthat/test-CreateTableOne.R | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/testthat/test-CreateTableOne.R b/tests/testthat/test-CreateTableOne.R index c4a3792..cc9c739 100644 --- a/tests/testthat/test-CreateTableOne.R +++ b/tests/testthat/test-CreateTableOne.R @@ -5,19 +5,21 @@ ## Author: Kazuki Yoshida ################################################################################ -### Structure -## expectations within tests within context - +### ### Prepare environment ################################################################################ library(testthat) + +### ### Context (1 for each file) +################################################################################ context("Unit tests for the CreateTableOne function") +### ### Load data - +################################################################################ library(survival) data(pbc) @@ -33,7 +35,10 @@ vars <- c("time","status","age","sex","ascites","hepato", varsContOnly <- c("time","age","protime") varsCatOnly <- c("status","trt","sex") + +### ### Tests for data checkers +################################################################################ test_that("abnormal data are correctly detected", { @@ -65,7 +70,9 @@ test_that("abnormal data are correctly detected", { }) +### ### Tests for ModuleTestSafe, a wrapper for test functions such as oneway.test and chisq.test +################################################################################ ## Create a dataset for a table dat <- read.table(header = TRUE, text = " @@ -134,8 +141,8 @@ test_that("P-values should be NA for 1xM xtabs", { }) - -### Regression tests +### +### Table construction and printing tests ################################################################################ ## Create a table to test @@ -240,6 +247,10 @@ test_that("dropEqual options correctly retail two-level categorical variable nam }) +### +### Regression tests for the print method +################################################################################ + test_that("printing of a TableOne object does not regress", { ## Expectations @@ -379,6 +390,9 @@ test_that("printing of a TableOne$ContTable object do not regress", { }) +### +### Tests for the summary method +################################################################################ test_that("summary method works without errors", { ## Expectations From 1b398500247679fba190cee6b13741cfa4768ce0 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sat, 28 Oct 2017 16:32:43 -0400 Subject: [PATCH 14/44] Add tests for varLabels option --- tests/testthat/test-CreateTableOne.R | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/testthat/test-CreateTableOne.R b/tests/testthat/test-CreateTableOne.R index cc9c739..5f43565 100644 --- a/tests/testthat/test-CreateTableOne.R +++ b/tests/testthat/test-CreateTableOne.R @@ -247,6 +247,45 @@ test_that("dropEqual options correctly retail two-level categorical variable nam }) +test_that("variable labels are correctly shown", { + + ## Construct a dataset with some variable labels. + pbc_labeled <- pbc + ## Continuous + age_label <- "Age in Years" + ## Two-level categorical + sex_label <- "Female Sex" + ## Multi-level categorical + stage_label <- "Stage of the Disease" + ## Apply labels + labelled::var_label(pbc_labeled$age) <- age_label + labelled::var_label(pbc_labeled$sex) <- sex_label + labelled::var_label(pbc_labeled$stage) <-stage_label + ## Show + labelled::var_label(pbc_labeled) + + ## Construct a TableOne object. + pbcOverall <- CreateTableOne(vars = vars, data = pbc_labeled) + + mat_default <- print(pbcOverall) + mat_labelled <- print(pbcOverall, varLabels = TRUE) + + ## Expectations + ## These must differ. + expect_false(identical(mat_default, mat_labelled)) + expect_false(identical(rownames(mat_default), rownames(mat_labelled))) + ## These labels should not exist in the original row names. + expect_true(sum(grepl(age_label, rownames(mat_default))) == 0) + expect_true(sum(grepl(sex_label, rownames(mat_default))) == 0) + expect_true(sum(grepl(stage_label, rownames(mat_default))) == 0) + ## These labels should appear only once in labelled table. + expect_true(sum(grepl(age_label, rownames(mat_labelled))) == 1) + expect_true(sum(grepl(sex_label, rownames(mat_labelled))) == 1) + expect_true(sum(grepl(stage_label, rownames(mat_labelled))) == 1) + +}) + + ### ### Regression tests for the print method ################################################################################ From 0619711bea1e6dec76067827b6a60119989851ec Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sat, 28 Oct 2017 16:36:59 -0400 Subject: [PATCH 15/44] Describe varLabels in NEWS --- NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS b/NEWS index 233aeb8..19ff7cb 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,12 @@ tableone 0.9.0 (2017-10-28) NEW FEATURES +* The "varLabels" option for the print.TableOne method was added. + When TRUE, instead of printing the variable names, their + corresponding variable labels are used. Variable labels must be + stored in the data frame to be used via labelled::var_label + function. + * The "dropEqual" option for the print methods was implemented. If TRUE, the level description for two-level variables such as " = 1" and " = TRUE" are not shown. This can obscure what level is being From 71a0ee2cde6dfe8c7e24d3a17bed77a07326295b Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sat, 28 Oct 2017 17:31:27 -0400 Subject: [PATCH 16/44] Update documents --- man/print.CatTable.Rd | 6 ++++-- man/print.TableOne.Rd | 9 +++++++-- man/print.svyCatTable.Rd | 6 ++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/man/print.CatTable.Rd b/man/print.CatTable.Rd index dd8021b..2097ac8 100644 --- a/man/print.CatTable.Rd +++ b/man/print.CatTable.Rd @@ -7,8 +7,8 @@ \method{print}{CatTable}(x, digits = 1, pDigits = 3, quote = FALSE, missing = FALSE, explain = TRUE, printToggle = TRUE, noSpaces = FALSE, format = c("fp", "f", "p", "pf")[1], showAllLevels = FALSE, - cramVars = NULL, test = TRUE, exact = NULL, smd = FALSE, - CrossTable = FALSE, ...) + cramVars = NULL, dropEqual = FALSE, test = TRUE, exact = NULL, + smd = FALSE, CrossTable = FALSE, ...) } \arguments{ \item{x}{Object returned by \code{\link{CreateCatTable}} function.} @@ -33,6 +33,8 @@ \item{cramVars}{A character vector to specify the two-level categorical variables, for which both levels should be shown in one row.} +\item{dropEqual}{Whether to drop " = second level name" description indicating which level is shown for two-level categorical variables.} + \item{test}{Whether to show p-values. TRUE by default. If FALSE, only the numerical summaries are shown.} \item{exact}{A character vector to specify the variables for which the p-values should be those of exact tests. By default all p-values are from large sample approximation tests (chisq.test).} diff --git a/man/print.TableOne.Rd b/man/print.TableOne.Rd index 66012f7..2d76ca7 100644 --- a/man/print.TableOne.Rd +++ b/man/print.TableOne.Rd @@ -7,8 +7,9 @@ \method{print}{TableOne}(x, catDigits = 1, contDigits = 2, pDigits = 3, quote = FALSE, missing = FALSE, explain = TRUE, printToggle = TRUE, test = TRUE, smd = FALSE, noSpaces = FALSE, padColnames = FALSE, - format = c("fp", "f", "p", "pf")[1], showAllLevels = FALSE, - cramVars = NULL, exact = NULL, nonnormal = NULL, minMax = FALSE, ...) + varLabels = FALSE, format = c("fp", "f", "p", "pf")[1], + showAllLevels = FALSE, cramVars = NULL, dropEqual = FALSE, + exact = NULL, nonnormal = NULL, minMax = FALSE, ...) } \arguments{ \item{x}{Object returned by \code{\link{CreateTableOne}} function.} @@ -35,12 +36,16 @@ \item{padColnames}{Whether to pad column names with spaces to center justify. The default is FALSE. It is not conducted if noSpaces = TRUE.} +\item{varLabels}{Whether to replace variable names with variable labels obtained from \code{labelled::var_label()} function.} + \item{format}{The default is "fp" frequency (percentage). You can also choose from "f" frequency only, "p" percentage only, and "pf" percentage (frequency).} \item{showAllLevels}{Whether to show all levels. FALSE by default, i.e., for 2-level categorical variables, only the higher level is shown to avoid redundant information.} \item{cramVars}{A character vector to specify the two-level categorical variables, for which both levels should be shown in one row.} +\item{dropEqual}{Whether to drop " = second level name" description indicating which level is shown for two-level categorical variables.} + \item{exact}{A character vector to specify the variables for which the p-values should be those of exact tests. By default all p-values are from large sample approximation tests (chisq.test).} \item{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).} diff --git a/man/print.svyCatTable.Rd b/man/print.svyCatTable.Rd index 7180298..f98f05b 100644 --- a/man/print.svyCatTable.Rd +++ b/man/print.svyCatTable.Rd @@ -7,8 +7,8 @@ \method{print}{svyCatTable}(x, digits = 1, pDigits = 3, quote = FALSE, missing = FALSE, explain = TRUE, printToggle = TRUE, noSpaces = FALSE, format = c("fp", "f", "p", "pf")[1], showAllLevels = FALSE, - cramVars = NULL, test = TRUE, exact = NULL, smd = FALSE, - CrossTable = FALSE, ...) + cramVars = NULL, dropEqual = FALSE, test = TRUE, exact = NULL, + smd = FALSE, CrossTable = FALSE, ...) } \arguments{ \item{x}{The result of a call to the \code{\link{svyCreateCatTable}} function.} @@ -33,6 +33,8 @@ \item{cramVars}{A character vector to specify the two-level categorical variables, for which both levels should be shown in one row.} +\item{dropEqual}{Whether to drop " = second level name" description indicating which level is shown for two-level categorical variables.} + \item{test}{Whether to show p-values. TRUE by default. If FALSE, only the numerical summaries are shown.} \item{exact}{This option is not available for tables from weighted data.} From 0d52361363a2753a687187d30043cd231f56d439 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sat, 28 Oct 2017 17:31:52 -0400 Subject: [PATCH 17/44] Add current test results (many new warnings due to lme4?) --- test-all.txt | 166 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 161 insertions(+), 5 deletions(-) diff --git a/test-all.txt b/test-all.txt index 01fcb09..e4f12ad 100644 --- a/test-all.txt +++ b/test-all.txt @@ -164,7 +164,131 @@ Unit tests for the CreateTableOne function: ....................... 2 35 (22.2) 32 ( 20.8) 3 56 (35.4) 64 ( 41.6) 4 55 (34.8) 54 ( 35.1) -. Stratified by trt +. + Overall + n 418 + time (mean (sd)) 1917.78 (1104.67) + status (%) + 0 232 (55.5) + 1 25 ( 6.0) + 2 161 (38.5) + age (mean (sd)) 50.74 (10.45) + sex = f (%) 374 (89.5) + ascites = 1 (%) 24 ( 7.7) + hepato = 1 (%) 160 (51.3) + spiders = 1 (%) 90 (28.8) + edema (%) + 0 354 (84.7) + 0.5 44 (10.5) + 1 20 ( 4.8) + bili (mean (sd)) 3.22 (4.41) + chol (mean (sd)) 369.51 (231.94) + albumin (mean (sd)) 3.50 (0.42) + copper (mean (sd)) 97.65 (85.61) + alk.phos (mean (sd)) 1982.66 (2140.39) + ast (mean (sd)) 122.56 (56.70) + trig (mean (sd)) 124.70 (65.15) + platelet (mean (sd)) 257.02 (98.33) + protime (mean (sd)) 10.73 (1.02) + stage (%) + 1 21 ( 5.1) + 2 92 (22.3) + 3 155 (37.6) + 4 144 (35.0) + + Overall + n 418 + time (mean (sd)) 1917.78 (1104.67) + status (%) + 0 232 (55.5) + 1 25 ( 6.0) + 2 161 (38.5) + age (mean (sd)) 50.74 (10.45) + sex (%) 374 (89.5) + ascites (%) 24 ( 7.7) + hepato (%) 160 (51.3) + spiders (%) 90 (28.8) + edema (%) + 0 354 (84.7) + 0.5 44 (10.5) + 1 20 ( 4.8) + bili (mean (sd)) 3.22 (4.41) + chol (mean (sd)) 369.51 (231.94) + albumin (mean (sd)) 3.50 (0.42) + copper (mean (sd)) 97.65 (85.61) + alk.phos (mean (sd)) 1982.66 (2140.39) + ast (mean (sd)) 122.56 (56.70) + trig (mean (sd)) 124.70 (65.15) + platelet (mean (sd)) 257.02 (98.33) + protime (mean (sd)) 10.73 (1.02) + stage (%) + 1 21 ( 5.1) + 2 92 (22.3) + 3 155 (37.6) + 4 144 (35.0) +..... + Overall + n 418 + time (mean (sd)) 1917.78 (1104.67) + status (%) + 0 232 (55.5) + 1 25 ( 6.0) + 2 161 (38.5) + age (mean (sd)) 50.74 (10.45) + sex = f (%) 374 (89.5) + ascites = 1 (%) 24 ( 7.7) + hepato = 1 (%) 160 (51.3) + spiders = 1 (%) 90 (28.8) + edema (%) + 0 354 (84.7) + 0.5 44 (10.5) + 1 20 ( 4.8) + bili (mean (sd)) 3.22 (4.41) + chol (mean (sd)) 369.51 (231.94) + albumin (mean (sd)) 3.50 (0.42) + copper (mean (sd)) 97.65 (85.61) + alk.phos (mean (sd)) 1982.66 (2140.39) + ast (mean (sd)) 122.56 (56.70) + trig (mean (sd)) 124.70 (65.15) + platelet (mean (sd)) 257.02 (98.33) + protime (mean (sd)) 10.73 (1.02) + stage (%) + 1 21 ( 5.1) + 2 92 (22.3) + 3 155 (37.6) + 4 144 (35.0) + + Overall + n 418 + time (mean (sd)) 1917.78 (1104.67) + status (%) + 0 232 (55.5) + 1 25 ( 6.0) + 2 161 (38.5) + Age in Years (mean (sd)) 50.74 (10.45) + Female Sex = f (%) 374 (89.5) + ascites = 1 (%) 24 ( 7.7) + hepato = 1 (%) 160 (51.3) + spiders = 1 (%) 90 (28.8) + edema (%) + 0 354 (84.7) + 0.5 44 (10.5) + 1 20 ( 4.8) + bili (mean (sd)) 3.22 (4.41) + chol (mean (sd)) 369.51 (231.94) + albumin (mean (sd)) 3.50 (0.42) + copper (mean (sd)) 97.65 (85.61) + alk.phos (mean (sd)) 1982.66 (2140.39) + ast (mean (sd)) 122.56 (56.70) + trig (mean (sd)) 124.70 (65.15) + platelet (mean (sd)) 257.02 (98.33) + protime (mean (sd)) 10.73 (1.02) + Stage of the Disease (%) + 1 21 ( 5.1) + 2 92 (22.3) + 3 155 (37.6) + 4 144 (35.0) +........ Stratified by trt 1 2 p test n 158 154 time (mean (sd)) 2015.62 (1094.12) 1996.86 (1155.93) 0.883 @@ -1994,15 +2118,15 @@ day 0.96758 [0.96225, 0.97295] <0.001 (Intercept) 2.70219 [2.51140, 2.89298] <0.001 trt -0.36806 [-0.57681, -0.15930] 0.001 day -0.06464 [-0.07910, -0.05017] <0.001 -.. coef [confint] p +..WWWW coef [confint] p (Intercept) 2.70219 [2.51320, 2.89118] 27.917 trt -0.36806 [-0.57306, -0.16305] -3.516 day -0.06464 [-0.07905, -0.05022] -8.807 -.. exp(coef) [confint] p +WW.WW.WWWW exp(coef) [confint] p (Intercept) 2.82371 [2.31045, 3.43231] <0.001 trt 0.82903 [0.70232, 0.97777] 0.026 day 0.96758 [0.94787, 0.98762] 0.002 -.. +WW.WW. Unit tests for svy* user functions: ................. Overall Missing n 450.01 @@ -2870,6 +2994,38 @@ C1 NaN NaN 0 0 0 .. Warnings --------------------------------------------------------------------------------------------------------------- -1. svyrep.design is allowed (@test-svyCreateTableOne.R#507) - No sampling weights provided: equal probability assumed +1. lme4 works (@test-ShowRegTable.R#192) - the condition has length > 1 and only the first element will be used + +2. lme4 works (@test-ShowRegTable.R#192) - the condition has length > 1 and only the first element will be used + +3. lme4 works (@test-ShowRegTable.R#195) - the condition has length > 1 and only the first element will be used + +4. lme4 works (@test-ShowRegTable.R#195) - the condition has length > 1 and only the first element will be used + +5. lme4 works (@test-ShowRegTable.R#196) - the condition has length > 1 and only the first element will be used + +6. lme4 works (@test-ShowRegTable.R#196) - the condition has length > 1 and only the first element will be used + +7. lme4 works (@test-ShowRegTable.R#202) - the condition has length > 1 and only the first element will be used + +8. lme4 works (@test-ShowRegTable.R#202) - the condition has length > 1 and only the first element will be used + +9. lme4 works (@test-ShowRegTable.R#211) - the condition has length > 1 and only the first element will be used + +10. lme4 works (@test-ShowRegTable.R#211) - the condition has length > 1 and only the first element will be used + +11. lme4 works (@test-ShowRegTable.R#214) - the condition has length > 1 and only the first element will be used + +12. lme4 works (@test-ShowRegTable.R#214) - the condition has length > 1 and only the first element will be used + +13. lme4 works (@test-ShowRegTable.R#215) - the condition has length > 1 and only the first element will be used + +14. lme4 works (@test-ShowRegTable.R#215) - the condition has length > 1 and only the first element will be used + +15. lme4 works (@test-ShowRegTable.R#221) - the condition has length > 1 and only the first element will be used + +16. lme4 works (@test-ShowRegTable.R#221) - the condition has length > 1 and only the first element will be used + +17. svyrep.design is allowed (@test-svyCreateTableOne.R#507) - No sampling weights provided: equal probability assumed DONE =================================================================================================================== From 3fb8709c341cbe821cdad5e9b716ab99abdf9695 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 15:18:35 -0400 Subject: [PATCH 18/44] Convert stage to factor to examine if label is correctly retained --- tests/testthat/test-CreateTableOne.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-CreateTableOne.R b/tests/testthat/test-CreateTableOne.R index 5f43565..6ef0739 100644 --- a/tests/testthat/test-CreateTableOne.R +++ b/tests/testthat/test-CreateTableOne.R @@ -265,7 +265,8 @@ test_that("variable labels are correctly shown", { labelled::var_label(pbc_labeled) ## Construct a TableOne object. - pbcOverall <- CreateTableOne(vars = vars, data = pbc_labeled) + ## Using factorVars should not break + pbcOverall <- CreateTableOne(vars = vars, data = pbc_labeled, factorVars = "stage") mat_default <- print(pbcOverall) mat_labelled <- print(pbcOverall, varLabels = TRUE) From 57a2a1acc3c23c0b284f228debbe14e136f56b09 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 15:21:43 -0400 Subject: [PATCH 19/44] Add failing results --- test-all.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test-all.txt b/test-all.txt index e4f12ad..94f8735 100644 --- a/test-all.txt +++ b/test-all.txt @@ -283,12 +283,12 @@ Unit tests for the CreateTableOne function: ....................... trig (mean (sd)) 124.70 (65.15) platelet (mean (sd)) 257.02 (98.33) protime (mean (sd)) 10.73 (1.02) - Stage of the Disease (%) + stage (%) 1 21 ( 5.1) 2 92 (22.3) 3 155 (37.6) 4 144 (35.0) -........ Stratified by trt +.......1 Stratified by trt 1 2 p test n 158 154 time (mean (sd)) 2015.62 (1094.12) 1996.86 (1155.93) 0.883 @@ -3028,4 +3028,9 @@ Warnings ----------------------------------------------------------------------- 17. svyrep.design is allowed (@test-svyCreateTableOne.R#507) - No sampling weights provided: equal probability assumed +Failed ----------------------------------------------------------------------------------------------------------------- +1. Failure: variable labels are correctly shown (@test-CreateTableOne.R#284) ------------------------------------------- +sum(grepl(stage_label, rownames(mat_labelled))) == 1 isn't true. + + DONE =================================================================================================================== From 1291de8cc4b002638eea468d2d006c9ea169b41c Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 15:21:58 -0400 Subject: [PATCH 20/44] Obtain variable labels before factor conversion --- R/CreateTableOne.R | 7 ++++--- R/svyCreateTableOne.R | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/R/CreateTableOne.R b/R/CreateTableOne.R index 0fb4e55..e593a32 100644 --- a/R/CreateTableOne.R +++ b/R/CreateTableOne.R @@ -129,6 +129,10 @@ function(vars, # character vector of variab ## Abort if no variables exist at this point ModuleStopIfNoVarsLeft(vars) + ## Get variable labels (named list of label string or NULL) + ## Need to occur before applying factor(). + varLabels <- labelled::var_label(data[vars]) + ## Factor conversions if the factorVars argument exist if (!missing(factorVars)) { ## Check if variables exist. Drop them if not. @@ -144,9 +148,6 @@ function(vars, # character vector of variab ## Get the missing percentage for each variable (no strata). percentMissing <- ModulePercentMissing(data[vars]) - ## Get variable labels (named list of label string or NULL) - varLabels <- labelled::var_label(data[vars]) - ## Get the classes of the variables varClasses <- lapply(data[vars], class) diff --git a/R/svyCreateTableOne.R b/R/svyCreateTableOne.R index 79a616c..80821da 100644 --- a/R/svyCreateTableOne.R +++ b/R/svyCreateTableOne.R @@ -103,6 +103,10 @@ function(vars, # character vector of variable ## Abort if no variables exist at this point ModuleStopIfNoVarsLeft(vars) + ## Get variable labels (named list of label string or NULL) + ## Need to occur before applying factor(). + varLabels <- labelled::var_label(data$variables[vars]) + ## Factor conversions if the factorVars argument exist if (!missing(factorVars)) { ## Check if variables exist. Drop them if not. @@ -118,9 +122,6 @@ function(vars, # character vector of variable ## Get the missing percentage for each variable (no strata). percentMissing <- ModulePercentMissing(data$variables[vars]) - ## Get variable labels (named list of label string or NULL) - varLabels <- labelled::var_label(data$variables[vars]) - ## Get the classes of the variables varClasses <- lapply(data$variables[vars], class) From f55d6d2aee28f245320df76d3e2a1a7a0b2d76d2 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 15:24:04 -0400 Subject: [PATCH 21/44] Add corrected results --- test-all.txt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test-all.txt b/test-all.txt index 94f8735..e4f12ad 100644 --- a/test-all.txt +++ b/test-all.txt @@ -283,12 +283,12 @@ Unit tests for the CreateTableOne function: ....................... trig (mean (sd)) 124.70 (65.15) platelet (mean (sd)) 257.02 (98.33) protime (mean (sd)) 10.73 (1.02) - stage (%) + Stage of the Disease (%) 1 21 ( 5.1) 2 92 (22.3) 3 155 (37.6) 4 144 (35.0) -.......1 Stratified by trt +........ Stratified by trt 1 2 p test n 158 154 time (mean (sd)) 2015.62 (1094.12) 1996.86 (1155.93) 0.883 @@ -3028,9 +3028,4 @@ Warnings ----------------------------------------------------------------------- 17. svyrep.design is allowed (@test-svyCreateTableOne.R#507) - No sampling weights provided: equal probability assumed -Failed ----------------------------------------------------------------------------------------------------------------- -1. Failure: variable labels are correctly shown (@test-CreateTableOne.R#284) ------------------------------------------- -sum(grepl(stage_label, rownames(mat_labelled))) == 1 isn't true. - - DONE =================================================================================================================== From eb64b60a72b5d6db86094e76d65874660e12ae25 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 16:05:57 -0400 Subject: [PATCH 22/44] Load lmerTest when testing for lme4 support --- DESCRIPTION | 3 ++- tests/testthat/test-ShowRegTable.R | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index abfa0f5..56b2010 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,7 +32,8 @@ Suggests: ggplot2, knitr, geepack, - lme4 + lme4, + lmerTest URL: https://github.com/kaz-yos/tableone VignetteBuilder: knitr RoxygenNote: 6.0.1 diff --git a/tests/testthat/test-ShowRegTable.R b/tests/testthat/test-ShowRegTable.R index ad20086..c9104cc 100644 --- a/tests/testthat/test-ShowRegTable.R +++ b/tests/testthat/test-ShowRegTable.R @@ -184,6 +184,8 @@ test_that("nlme works", { test_that("lme4 works", { library(lme4) + ## Need this for p-values + library(lmerTest) ## Linear LME lmer1 <- lmer(formula = y ~ trt + day + (1 | id), From 902004373ba7ad4409adda4d1ef1abd56bc75ab1 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 16:48:55 -0400 Subject: [PATCH 23/44] Handle merModLmerTest object from lmerTest::lmer() --- R/ShowRegTable.R | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/R/ShowRegTable.R b/R/ShowRegTable.R index 1906188..960862a 100644 --- a/R/ShowRegTable.R +++ b/R/ShowRegTable.R @@ -46,8 +46,9 @@ ShowRegTable <- function(model, exp = TRUE, digits = 2, pDigits = 3, printToggle ## nlme needs special handling ## Use column 2 because it is the point estimate modelCoef <- nlme::intervals(model)[[1]][, 2] - } else if (any(class(model) %in% c("lmerMod","glmerMod"))) { + } else if (any(class(model) %in% c("lmerMod","glmerMod","merModLmerTest"))) { ## (g)lmer gives confint for other extra parameters + ## lmerTest::lmer() gives a merModLmerTest object. modelCoef <- coef(summary(model))[,1] } else { modelCoef <- coef(model) @@ -58,8 +59,9 @@ ShowRegTable <- function(model, exp = TRUE, digits = 2, pDigits = 3, printToggle ## nlme needs special handling ## Drop column 2 because it is the point estimate modelConfInt <- nlme::intervals(model)[[1]][, -2] - } else if (any(class(model) %in% c("lmerMod","glmerMod"))) { - ## (g)lmer gives confint for other extra parameters + } else if (any(class(model) %in% c("lmerMod","glmerMod","merModLmerTest"))) { + ## (g)lmer gives confint for other extra parameters. + ## The bottom ones are for fixed effects. modelConfInt <- tail(suppressMessages(ciFun(model)), length(modelCoef)) } else { modelConfInt <- suppressMessages(ciFun(model)) @@ -69,6 +71,11 @@ ShowRegTable <- function(model, exp = TRUE, digits = 2, pDigits = 3, printToggle if (any(class(model) %in% c("gls", "lme"))) { ## nlme needs special handling modelSummaryMat <- summary(model)$tTable + } else if (any(class(model) %in% c("lmerMod"))) { + ## lmerMod does not have p-values, add NA's + modelSummaryMat <- coef(summary(model)) + modelSummaryMat <- cbind(modelSummaryMat, + rep(NA, nrow(modelSummaryMat))) } else { modelSummaryMat <- coef(summary(model)) } From 7362b420fa34c996e51bdda73cad6ba06d43e919 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 16:51:26 -0400 Subject: [PATCH 24/44] Add tests for merModLmerTest --- tests/testthat/test-ShowRegTable.R | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-ShowRegTable.R b/tests/testthat/test-ShowRegTable.R index c9104cc..811976b 100644 --- a/tests/testthat/test-ShowRegTable.R +++ b/tests/testthat/test-ShowRegTable.R @@ -184,8 +184,6 @@ test_that("nlme works", { test_that("lme4 works", { library(lme4) - ## Need this for p-values - library(lmerTest) ## Linear LME lmer1 <- lmer(formula = y ~ trt + day + (1 | id), @@ -205,6 +203,32 @@ test_that("lme4 works", { sprintf("%.5f", coef(summary(lmer1))[2,1])) + ## For p-values + ## lmerTest::lmer() masks lme4::lmer() + library(lmerTest) + + ## Linear LME + lmer2 <- lmer(formula = y ~ trt + day + (1 | id), + data = koch) + + ciLmer2 <- tail(confint(lmer2), nrow(coef(summary(lmer2)))) + + ## confint + ShowRegTable(lmer2, digits = 5, exp = FALSE) + expect_output(ShowRegTable(lmer2, digits = 5, exp = FALSE), + sprintf("%.5f, %.5f", + ciLmer2[2,1], + ciLmer2[2,2])) + + ## coef + expect_output(ShowRegTable(lmer2, digits = 5, exp = FALSE), + sprintf("%.5f", coef(summary(lmer2))[2,1])) + + ## p-value + expect_output(ShowRegTable(lmer2, digits = 5, exp = FALSE), + sprintf("%.5f", coef(summary(lmer2))[2,4])) + + ## GLMM glmer1 <- glmer(formula = y ~ trt + day + (1 | id), data = koch, From 56414bc79b98480de0c3faaf955bbf1e375b3b4b Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 21:42:32 -0400 Subject: [PATCH 25/44] Add updated results --- test-all.txt | 53 ++++++++++++++-------------------------------------- 1 file changed, 14 insertions(+), 39 deletions(-) diff --git a/test-all.txt b/test-all.txt index e4f12ad..cb8fa76 100644 --- a/test-all.txt +++ b/test-all.txt @@ -2118,15 +2118,15 @@ day 0.96758 [0.96225, 0.97295] <0.001 (Intercept) 2.70219 [2.51140, 2.89298] <0.001 trt -0.36806 [-0.57681, -0.15930] 0.001 day -0.06464 [-0.07910, -0.05017] <0.001 -..WWWW coef [confint] p +.. coef [confint] p +(Intercept) 2.70219 [2.51320, 2.89118] NA +trt -0.36806 [-0.57306, -0.16305] NA +day -0.06464 [-0.07905, -0.05022] NA +.. coef [confint] p (Intercept) 2.70219 [2.51320, 2.89118] 27.917 trt -0.36806 [-0.57306, -0.16305] -3.516 day -0.06464 [-0.07905, -0.05022] -8.807 -WW.WW.WWWW exp(coef) [confint] p -(Intercept) 2.82371 [2.31045, 3.43231] <0.001 -trt 0.82903 [0.70232, 0.97777] 0.026 -day 0.96758 [0.94787, 0.98762] 0.002 -WW.WW. +..1 Unit tests for svy* user functions: ................. Overall Missing n 450.01 @@ -2994,38 +2994,13 @@ C1 NaN NaN 0 0 0 .. Warnings --------------------------------------------------------------------------------------------------------------- -1. lme4 works (@test-ShowRegTable.R#192) - the condition has length > 1 and only the first element will be used - -2. lme4 works (@test-ShowRegTable.R#192) - the condition has length > 1 and only the first element will be used - -3. lme4 works (@test-ShowRegTable.R#195) - the condition has length > 1 and only the first element will be used - -4. lme4 works (@test-ShowRegTable.R#195) - the condition has length > 1 and only the first element will be used - -5. lme4 works (@test-ShowRegTable.R#196) - the condition has length > 1 and only the first element will be used - -6. lme4 works (@test-ShowRegTable.R#196) - the condition has length > 1 and only the first element will be used - -7. lme4 works (@test-ShowRegTable.R#202) - the condition has length > 1 and only the first element will be used - -8. lme4 works (@test-ShowRegTable.R#202) - the condition has length > 1 and only the first element will be used - -9. lme4 works (@test-ShowRegTable.R#211) - the condition has length > 1 and only the first element will be used - -10. lme4 works (@test-ShowRegTable.R#211) - the condition has length > 1 and only the first element will be used - -11. lme4 works (@test-ShowRegTable.R#214) - the condition has length > 1 and only the first element will be used - -12. lme4 works (@test-ShowRegTable.R#214) - the condition has length > 1 and only the first element will be used - -13. lme4 works (@test-ShowRegTable.R#215) - the condition has length > 1 and only the first element will be used - -14. lme4 works (@test-ShowRegTable.R#215) - the condition has length > 1 and only the first element will be used - -15. lme4 works (@test-ShowRegTable.R#221) - the condition has length > 1 and only the first element will be used - -16. lme4 works (@test-ShowRegTable.R#221) - the condition has length > 1 and only the first element will be used - -17. svyrep.design is allowed (@test-svyCreateTableOne.R#507) - No sampling weights provided: equal probability assumed +1. svyrep.design is allowed (@test-svyCreateTableOne.R#507) - No sampling weights provided: equal probability assumed + +Failed ----------------------------------------------------------------------------------------------------------------- +1. Error: lme4 works (@test-ShowRegTable.R#228) ------------------------------------------------------------------------ +subscript out of bounds +1: expect_output(ShowRegTable(lmer2, digits = 5, exp = FALSE), sprintf("%.5f", coef(summary(lmer2))[2, 4])) at /Users/kazuki/Documents/programming/r/tableone/tests/testthat/test-ShowRegTable.R:228 +2: identical(regexp, NA) +3: sprintf("%.5f", coef(summary(lmer2))[2, 4]) DONE =================================================================================================================== From 30566a91a8ffe13afd47118e874efbd0dd42ed15 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 21:58:02 -0400 Subject: [PATCH 26/44] Fix test for p-value in lmerTest --- R/ShowRegTable.R | 2 +- tests/testthat/test-ShowRegTable.R | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/ShowRegTable.R b/R/ShowRegTable.R index 960862a..64a2590 100644 --- a/R/ShowRegTable.R +++ b/R/ShowRegTable.R @@ -67,7 +67,7 @@ ShowRegTable <- function(model, exp = TRUE, digits = 2, pDigits = 3, printToggle modelConfInt <- suppressMessages(ciFun(model)) } - ## P-value extraction + ## Extract p-values if (any(class(model) %in% c("gls", "lme"))) { ## nlme needs special handling modelSummaryMat <- summary(model)$tTable diff --git a/tests/testthat/test-ShowRegTable.R b/tests/testthat/test-ShowRegTable.R index 811976b..fa9738d 100644 --- a/tests/testthat/test-ShowRegTable.R +++ b/tests/testthat/test-ShowRegTable.R @@ -225,8 +225,8 @@ test_that("lme4 works", { sprintf("%.5f", coef(summary(lmer2))[2,1])) ## p-value - expect_output(ShowRegTable(lmer2, digits = 5, exp = FALSE), - sprintf("%.5f", coef(summary(lmer2))[2,4])) + expect_output(ShowRegTable(lmer2, pDigits = 5, exp = FALSE), + sprintf("%.5f", coef(summary(lmer2))[2,5])) ## GLMM From eed2b78440f45605a6b4d1ea9168da036b5f69aa Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 22:13:52 -0400 Subject: [PATCH 27/44] Do not test under lme4 1.1-14 --- tests/testthat/test-ShowRegTable.R | 68 ++++++++++++++++-------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/tests/testthat/test-ShowRegTable.R b/tests/testthat/test-ShowRegTable.R index fa9738d..01cd176 100644 --- a/tests/testthat/test-ShowRegTable.R +++ b/tests/testthat/test-ShowRegTable.R @@ -185,49 +185,53 @@ test_that("lme4 works", { library(lme4) - ## Linear LME - lmer1 <- lmer(formula = y ~ trt + day + (1 | id), - data = koch) + ## Do not test in version 1.1-14 to avoid warnings. + ## https://github.com/lme4/lme4/issues/440 + if (sessionInfo()$otherPkgs$lme4$Version != "1.1-14") { - ciLmer1 <- tail(confint(lmer1), nrow(coef(summary(lmer1)))) + ## Linear LME + lmer1 <- lmer(formula = y ~ trt + day + (1 | id), + data = koch) - ## confint - ShowRegTable(lmer1, digits = 5, exp = FALSE) - expect_output(ShowRegTable(lmer1, digits = 5, exp = FALSE), - sprintf("%.5f, %.5f", - ciLmer1[2,1], - ciLmer1[2,2])) + ciLmer1 <- tail(confint(lmer1), nrow(coef(summary(lmer1)))) - ## coef - expect_output(ShowRegTable(lmer1, digits = 5, exp = FALSE), - sprintf("%.5f", coef(summary(lmer1))[2,1])) + ## confint + ShowRegTable(lmer1, digits = 5, exp = FALSE) + expect_output(ShowRegTable(lmer1, digits = 5, exp = FALSE), + sprintf("%.5f, %.5f", + ciLmer1[2,1], + ciLmer1[2,2])) + ## coef + expect_output(ShowRegTable(lmer1, digits = 5, exp = FALSE), + sprintf("%.5f", coef(summary(lmer1))[2,1])) - ## For p-values - ## lmerTest::lmer() masks lme4::lmer() - library(lmerTest) - ## Linear LME - lmer2 <- lmer(formula = y ~ trt + day + (1 | id), - data = koch) + ## For p-values + ## lmerTest::lmer() masks lme4::lmer() + library(lmerTest) - ciLmer2 <- tail(confint(lmer2), nrow(coef(summary(lmer2)))) + ## Linear LME + lmer2 <- lmer(formula = y ~ trt + day + (1 | id), + data = koch) - ## confint - ShowRegTable(lmer2, digits = 5, exp = FALSE) - expect_output(ShowRegTable(lmer2, digits = 5, exp = FALSE), - sprintf("%.5f, %.5f", - ciLmer2[2,1], - ciLmer2[2,2])) + ciLmer2 <- tail(confint(lmer2), nrow(coef(summary(lmer2)))) - ## coef - expect_output(ShowRegTable(lmer2, digits = 5, exp = FALSE), - sprintf("%.5f", coef(summary(lmer2))[2,1])) + ## confint + ShowRegTable(lmer2, digits = 5, exp = FALSE) + expect_output(ShowRegTable(lmer2, digits = 5, exp = FALSE), + sprintf("%.5f, %.5f", + ciLmer2[2,1], + ciLmer2[2,2])) - ## p-value - expect_output(ShowRegTable(lmer2, pDigits = 5, exp = FALSE), - sprintf("%.5f", coef(summary(lmer2))[2,5])) + ## coef + expect_output(ShowRegTable(lmer2, digits = 5, exp = FALSE), + sprintf("%.5f", coef(summary(lmer2))[2,1])) + ## p-value + expect_output(ShowRegTable(lmer2, pDigits = 5, exp = FALSE), + sprintf("%.5f", coef(summary(lmer2))[2,5])) + } ## GLMM glmer1 <- glmer(formula = y ~ trt + day + (1 | id), From 05c8fa776a97bf5de0b92ea75fedd47fb9b0bf34 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 22:14:44 -0400 Subject: [PATCH 28/44] Add still-failing results --- test-all.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test-all.txt b/test-all.txt index cb8fa76..51c4140 100644 --- a/test-all.txt +++ b/test-all.txt @@ -2997,10 +2997,10 @@ Warnings ----------------------------------------------------------------------- 1. svyrep.design is allowed (@test-svyCreateTableOne.R#507) - No sampling weights provided: equal probability assumed Failed ----------------------------------------------------------------------------------------------------------------- -1. Error: lme4 works (@test-ShowRegTable.R#228) ------------------------------------------------------------------------ +1. Error: lme4 works (@test-ShowRegTable.R#232) ------------------------------------------------------------------------ subscript out of bounds -1: expect_output(ShowRegTable(lmer2, digits = 5, exp = FALSE), sprintf("%.5f", coef(summary(lmer2))[2, 4])) at /Users/kazuki/Documents/programming/r/tableone/tests/testthat/test-ShowRegTable.R:228 +1: expect_output(ShowRegTable(lmer2, pDigits = 5, exp = FALSE), sprintf("%.5f", coef(summary(lmer2))[2, 5])) at /Users/kazuki/Documents/programming/r/tableone/tests/testthat/test-ShowRegTable.R:232 2: identical(regexp, NA) -3: sprintf("%.5f", coef(summary(lmer2))[2, 4]) +3: sprintf("%.5f", coef(summary(lmer2))[2, 5]) DONE =================================================================================================================== From 4478e4083db9bd8a354e51409c83cc50753b9d4f Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 22:28:44 -0400 Subject: [PATCH 29/44] Explicitly use lmerTest::summary() --- R/ShowRegTable.R | 3 +++ tests/testthat/test-ShowRegTable.R | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/R/ShowRegTable.R b/R/ShowRegTable.R index 64a2590..6faf6b7 100644 --- a/R/ShowRegTable.R +++ b/R/ShowRegTable.R @@ -76,6 +76,9 @@ ShowRegTable <- function(model, exp = TRUE, digits = 2, pDigits = 3, printToggle modelSummaryMat <- coef(summary(model)) modelSummaryMat <- cbind(modelSummaryMat, rep(NA, nrow(modelSummaryMat))) + } else if (any(class(model) %in% c("merModLmerTest"))) { + ## Need to specify explicitly to invoke the correct summary method. + modelSummaryMat <- coef(lmerTest::summary(model)) } else { modelSummaryMat <- coef(summary(model)) } diff --git a/tests/testthat/test-ShowRegTable.R b/tests/testthat/test-ShowRegTable.R index 01cd176..020df67 100644 --- a/tests/testthat/test-ShowRegTable.R +++ b/tests/testthat/test-ShowRegTable.R @@ -229,8 +229,9 @@ test_that("lme4 works", { sprintf("%.5f", coef(summary(lmer2))[2,1])) ## p-value + ## For some reason, need to specify summary explicitly. expect_output(ShowRegTable(lmer2, pDigits = 5, exp = FALSE), - sprintf("%.5f", coef(summary(lmer2))[2,5])) + sprintf("%.5f", coef(lmerTest::summary(lmer2))[2,5])) } ## GLMM From 9808b83de0c6a2b4e37fb1c09b8f9d8bd7ad342b Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 22:33:15 -0400 Subject: [PATCH 30/44] Import lmerTest to use lmerTest::summary() --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 56b2010..c099545 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,6 +21,7 @@ Imports: zoo, gmodels, nlme, + lmerTest, labelled Suggests: survival, @@ -32,8 +33,7 @@ Suggests: ggplot2, knitr, geepack, - lme4, - lmerTest + lme4 URL: https://github.com/kaz-yos/tableone VignetteBuilder: knitr RoxygenNote: 6.0.1 From 5c5ad3a1231dfcc90918ea599e891a3c029af233 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Wed, 1 Nov 2017 22:41:57 -0400 Subject: [PATCH 31/44] Add correct lmer p-value results --- test-all.txt | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/test-all.txt b/test-all.txt index 51c4140..9b99b23 100644 --- a/test-all.txt +++ b/test-all.txt @@ -2122,11 +2122,15 @@ day -0.06464 [-0.07910, -0.05017] <0.001 (Intercept) 2.70219 [2.51320, 2.89118] NA trt -0.36806 [-0.57306, -0.16305] NA day -0.06464 [-0.07905, -0.05022] NA -.. coef [confint] p -(Intercept) 2.70219 [2.51320, 2.89118] 27.917 -trt -0.36806 [-0.57306, -0.16305] -3.516 -day -0.06464 [-0.07905, -0.05022] -8.807 -..1 +.. coef [confint] p +(Intercept) 2.70219 [2.51320, 2.89118] <0.001 +trt -0.36806 [-0.57306, -0.16305] 0.001 +day -0.06464 [-0.07905, -0.05022] <0.001 +... exp(coef) [confint] p +(Intercept) 2.82371 [2.31045, 3.43231] <0.001 +trt 0.82903 [0.70232, 0.97777] 0.026 +day 0.96758 [0.94787, 0.98762] 0.002 +.. Unit tests for svy* user functions: ................. Overall Missing n 450.01 @@ -2996,11 +3000,4 @@ C1 NaN NaN 0 0 0 Warnings --------------------------------------------------------------------------------------------------------------- 1. svyrep.design is allowed (@test-svyCreateTableOne.R#507) - No sampling weights provided: equal probability assumed -Failed ----------------------------------------------------------------------------------------------------------------- -1. Error: lme4 works (@test-ShowRegTable.R#232) ------------------------------------------------------------------------ -subscript out of bounds -1: expect_output(ShowRegTable(lmer2, pDigits = 5, exp = FALSE), sprintf("%.5f", coef(summary(lmer2))[2, 5])) at /Users/kazuki/Documents/programming/r/tableone/tests/testthat/test-ShowRegTable.R:232 -2: identical(regexp, NA) -3: sprintf("%.5f", coef(summary(lmer2))[2, 5]) - DONE =================================================================================================================== From 7440faffebed4ba812fbb4b644dc354ed03b6f37 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Thu, 2 Nov 2017 09:18:18 -0400 Subject: [PATCH 32/44] Add test results (failing) --- cran-check.txt | 4 ++-- tableone.Rcheck/tableone-Ex.Rout | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cran-check.txt b/cran-check.txt index 64afa5c..2467a8b 100644 --- a/cran-check.txt +++ b/cran-check.txt @@ -1,11 +1,11 @@ * using log directory ‘/Users/kazuki/Documents/programming/r/tableone/tableone.Rcheck’ -* using R version 3.4.1 (2017-06-30) +* using R version 3.4.2 (2017-09-28) * using platform: x86_64-apple-darwin15.6.0 (64-bit) * using session charset: UTF-8 * using option ‘--as-cran’ * checking for file ‘tableone/DESCRIPTION’ ... OK * checking extension type ... Package -* this is package ‘tableone’ version ‘0.8.2’ +* this is package ‘tableone’ version ‘0.9.0’ * checking CRAN incoming feasibility ... Note_to_CRAN_maintainers Maintainer: ‘Kazuki Yoshida ’ * checking package namespace information ... OK diff --git a/tableone.Rcheck/tableone-Ex.Rout b/tableone.Rcheck/tableone-Ex.Rout index 19e2458..0e9727e 100644 --- a/tableone.Rcheck/tableone-Ex.Rout +++ b/tableone.Rcheck/tableone-Ex.Rout @@ -1,5 +1,5 @@ -R version 3.4.1 (2017-06-30) -- "Single Candle" +R version 3.4.2 (2017-09-28) -- "Short Summer" Copyright (C) 2017 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin15.6.0 (64-bit) @@ -3166,8 +3166,9 @@ _U_s_a_g_e: print(x, catDigits = 1, contDigits = 2, pDigits = 3, quote = FALSE, missing = FALSE, explain = TRUE, printToggle = TRUE, test = TRUE, smd = FALSE, noSpaces = FALSE, padColnames = FALSE, - format = c("fp", "f", "p", "pf")[1], showAllLevels = FALSE, - cramVars = NULL, exact = NULL, nonnormal = NULL, minMax = FALSE, ...) + varLabels = FALSE, format = c("fp", "f", "p", "pf")[1], + showAllLevels = FALSE, cramVars = NULL, dropEqual = FALSE, + exact = NULL, nonnormal = NULL, minMax = FALSE, ...) _A_r_g_u_m_e_n_t_s: @@ -3207,6 +3208,9 @@ noSpaces: Whether to remove spaces added for alignment. Use this option padColnames: Whether to pad column names with spaces to center justify. The default is FALSE. It is not conducted if noSpaces = TRUE. +varLabels: Whether to replace variable names with variable labels + obtained from ‘labelled::var_label()’ function. + format: The default is "fp" frequency (percentage). You can also choose from "f" frequency only, "p" percentage only, and "pf" percentage (frequency). @@ -3218,6 +3222,10 @@ showAllLevels: Whether to show all levels. FALSE by default, i.e., for cramVars: A character vector to specify the two-level categorical variables, for which both levels should be shown in one row. +dropEqual: Whether to drop " = second level name" description + indicating which level is shown for two-level categorical + variables. + exact: A character vector to specify the variables for which the p-values should be those of exact tests. By default all p-values are from large sample approximation tests @@ -3316,7 +3324,7 @@ detaching ‘package:survey’, ‘package:survival’, ‘package:Matrix’, > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 6.262 0.206 6.628 0.004 0.003 +Time elapsed: 6.538 0.228 7.029 0.005 0.004 > grDevices::dev.off() null device 1 From 63b614e9abbb49b317c0aff827f2f015a804e79d Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Thu, 2 Nov 2017 09:27:08 -0400 Subject: [PATCH 33/44] Support variable labels in ExtractSmd() --- R/ExtractSmd.R | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/R/ExtractSmd.R b/R/ExtractSmd.R index c5161ed..f0ebb5e 100644 --- a/R/ExtractSmd.R +++ b/R/ExtractSmd.R @@ -4,6 +4,8 @@ ##' ##' ##' @param x A stratified (svy)TableOne object containing standardized mean differences. +##' @param varLabels Whether to replace variable names with variable labels obtained from \code{labelled::var_label()} function. +##' ##' @return A vector or matrix containing the average standardized mean differences (if more than two contrasts exist) as well as the all possible pairwise standardized mean differences. Variables are ordered in the same order as the printed table. ##' @author Kazuki Yoshida ##' @seealso @@ -13,7 +15,7 @@ ##' ## See examples for CreateTableOne and svyCreateTableOne ##' ##' @export -ExtractSmd <- function(x) { +ExtractSmd <- function(x, varLabels = FALSE) { if (class(x)[1] %in% c("TableOne","svyTableOne")) { @@ -22,7 +24,20 @@ ExtractSmd <- function(x) { attr(x$CatTable, "smd")) ## Order by table variable order - matSmd[x$MetaData$vars,] + matSmd <- matSmd[x$MetaData$vars,] + + ## Use variable labels if requested. + if (varLabels) { + for (i in seq_along(x$MetaData$vars)) { + if (!is.null(x$MetaData$varLabels[[i]])) { + ## If the corresponding variable label is non-null replace + rownames(matSmd)[i] <- x$MetaData$varLabels[[i]] + } + } + } + + ## Return manipulated matrix + matSmd } else if (class(x)[1] %in% c("ContTable","svyContTable","CatTable","svyCatTable")) { From 133605ef42f26f6135b7d51ae4a49efb89471f67 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Fri, 3 Nov 2017 21:00:01 -0400 Subject: [PATCH 34/44] Update doc for ExtractSmd --- man/ExtractSmd.Rd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/man/ExtractSmd.Rd b/man/ExtractSmd.Rd index dc2d4f8..9d8cb50 100644 --- a/man/ExtractSmd.Rd +++ b/man/ExtractSmd.Rd @@ -4,10 +4,12 @@ \alias{ExtractSmd} \title{Extract standardized mean differences from a (svy)TableOne object} \usage{ -ExtractSmd(x) +ExtractSmd(x, varLabels = FALSE) } \arguments{ \item{x}{A stratified (svy)TableOne object containing standardized mean differences.} + +\item{varLabels}{Whether to replace variable names with variable labels obtained from \code{labelled::var_label()} function.} } \value{ A vector or matrix containing the average standardized mean differences (if more than two contrasts exist) as well as the all possible pairwise standardized mean differences. Variables are ordered in the same order as the printed table. From 8528941fd12d149e5f624eb2875cadfe52b49d8d Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Fri, 3 Nov 2017 21:03:36 -0400 Subject: [PATCH 35/44] Update NEWS/DESCRIPTION --- DESCRIPTION | 2 +- NEWS | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c099545..bded706 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: tableone Type: Package Title: Create 'Table 1' to Describe Baseline Characteristics Version: 0.9.0 -Date: 2017-10-25 +Date: 2017-11-03 Author: Kazuki Yoshida, Justin Bohn. Maintainer: Kazuki Yoshida Description: Creates 'Table 1', i.e., description of baseline patient diff --git a/NEWS b/NEWS index 19ff7cb..be6cfdc 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -tableone 0.9.0 (2017-10-28) +tableone 0.9.0 (2017-11-03) ---------------------------------------------------------------- NEW FEATURES @@ -7,7 +7,7 @@ NEW FEATURES When TRUE, instead of printing the variable names, their corresponding variable labels are used. Variable labels must be stored in the data frame to be used via labelled::var_label - function. + function. This option is also available in ExtractSmd function. * The "dropEqual" option for the print methods was implemented. If TRUE, the level description for two-level variables such as " = 1" @@ -15,6 +15,10 @@ NEW FEATURES shown depending on the variable naming scheme, thus, should only be used after the initial results were checked for correctness. +BUG FIXES + +* Handling of lme4 models was improved in ShowRegTable. + tableone 0.8.2 (2017-08-31) ---------------------------------------------------------------- From bca20ed8972e37d25ed0a3aec7027a2225c781b5 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Fri, 3 Nov 2017 21:08:12 -0400 Subject: [PATCH 36/44] Add tentative cran comment --- cran-comment.md | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/cran-comment.md b/cran-comment.md index a7d824a..4d3c791 100644 --- a/cran-comment.md +++ b/cran-comment.md @@ -1,14 +1,30 @@ ## What's new The following changes are included. -tableone 0.8.2 (2017-08-31) +tableone 0.9.0 (2017-11-03) ---------------------------------------------------------------- -BUG FIX -* Handle labelled class as categorical. + +NEW FEATURES + +* The "varLabels" option for the print.TableOne method was added. + When TRUE, instead of printing the variable names, their + corresponding variable labels are used. Variable labels must be + stored in the data frame to be used via labelled::var_label + function. This option is also available in ExtractSmd function. + +* The "dropEqual" option for the print methods was implemented. If + TRUE, the level description for two-level variables such as " = 1" + and " = TRUE" are not shown. This can obscure what level is being + shown depending on the variable naming scheme, thus, should only + be used after the initial results were checked for correctness. + +BUG FIXES + +* Handling of lme4 models was improved in ShowRegTable. ## Test environments -* Local OS X 10.12.6, R 3.4.1 +* Local OS X 10.12.6, R 3.4.2 * Ubuntu Linux on Travis-CI (oldrel, release, and devel) * win-builder (release and devel) From 69b5b56265239ab5cf8145478281e4b31228ad6a Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Fri, 3 Nov 2017 21:43:23 -0400 Subject: [PATCH 37/44] Change test strategy to avoid issues lme4 1.1-14 --- tests/testthat/test-ShowRegTable.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-ShowRegTable.R b/tests/testthat/test-ShowRegTable.R index 020df67..186638b 100644 --- a/tests/testthat/test-ShowRegTable.R +++ b/tests/testthat/test-ShowRegTable.R @@ -187,7 +187,7 @@ test_that("lme4 works", { ## Do not test in version 1.1-14 to avoid warnings. ## https://github.com/lme4/lme4/issues/440 - if (sessionInfo()$otherPkgs$lme4$Version != "1.1-14") { + if (installed.packages()["lme4","Version"] != "1.1-14") { ## Linear LME lmer1 <- lmer(formula = y ~ trt + day + (1 | id), From 7a850deabed55b5fa0333e77f8bdc72e7ba51b83 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Fri, 3 Nov 2017 21:46:11 -0400 Subject: [PATCH 38/44] Fix typo --- tests/testthat/test-ShowRegTable.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-ShowRegTable.R b/tests/testthat/test-ShowRegTable.R index 186638b..4309fc6 100644 --- a/tests/testthat/test-ShowRegTable.R +++ b/tests/testthat/test-ShowRegTable.R @@ -239,7 +239,7 @@ test_that("lme4 works", { data = koch, family = poisson(link = "log")) ## Last rows correspond to fixed effects - ciGlmer1 <- tail(confint(glmer1), nrow(coef(summary(lmer1)))) + ciGlmer1 <- tail(confint(glmer1), nrow(coef(summary(glmer1)))) ## confint ShowRegTable(glmer1, digits = 5, exp = TRUE) From 8ccbca7233a25e5768dd3b38a3813c0489e656c2 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Fri, 3 Nov 2017 21:56:49 -0400 Subject: [PATCH 39/44] Show lme4 results to indicate where it is --- tests/testthat/test-ShowRegTable.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/testthat/test-ShowRegTable.R b/tests/testthat/test-ShowRegTable.R index 4309fc6..56c72e0 100644 --- a/tests/testthat/test-ShowRegTable.R +++ b/tests/testthat/test-ShowRegTable.R @@ -189,11 +189,14 @@ test_that("lme4 works", { ## https://github.com/lme4/lme4/issues/440 if (installed.packages()["lme4","Version"] != "1.1-14") { + cat("### Testing lmer lme4 is version", installed.packages()["lme4","Version"], "\n") + ## Linear LME lmer1 <- lmer(formula = y ~ trt + day + (1 | id), data = koch) ciLmer1 <- tail(confint(lmer1), nrow(coef(summary(lmer1)))) + summary(lmer1) ## confint ShowRegTable(lmer1, digits = 5, exp = FALSE) @@ -214,6 +217,7 @@ test_that("lme4 works", { ## Linear LME lmer2 <- lmer(formula = y ~ trt + day + (1 | id), data = koch) + summary(lmer2) ciLmer2 <- tail(confint(lmer2), nrow(coef(summary(lmer2)))) @@ -238,6 +242,7 @@ test_that("lme4 works", { glmer1 <- glmer(formula = y ~ trt + day + (1 | id), data = koch, family = poisson(link = "log")) + summary(glmer1) ## Last rows correspond to fixed effects ciGlmer1 <- tail(confint(glmer1), nrow(coef(summary(glmer1)))) From 9bbe376b1360c6994c64b1b1369f33c718b3c457 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Fri, 3 Nov 2017 21:58:55 -0400 Subject: [PATCH 40/44] Also do not test glmer with lme4 1.1-14 --- tests/testthat/test-ShowRegTable.R | 43 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/tests/testthat/test-ShowRegTable.R b/tests/testthat/test-ShowRegTable.R index 56c72e0..7fe6042 100644 --- a/tests/testthat/test-ShowRegTable.R +++ b/tests/testthat/test-ShowRegTable.R @@ -183,13 +183,16 @@ test_that("nlme works", { ### lme4 test_that("lme4 works", { - library(lme4) + cat("### The lme4 version is ", installed.packages()["lme4","Version"], "\n") + + if (installed.packages()["lme4","Version"] == "1.1-14") { + cat("### Due to the issues with lme4 1.1-14. The relevant test are skipped.\n") + } ## Do not test in version 1.1-14 to avoid warnings. ## https://github.com/lme4/lme4/issues/440 if (installed.packages()["lme4","Version"] != "1.1-14") { - - cat("### Testing lmer lme4 is version", installed.packages()["lme4","Version"], "\n") + library(lme4) ## Linear LME lmer1 <- lmer(formula = y ~ trt + day + (1 | id), @@ -236,25 +239,25 @@ test_that("lme4 works", { ## For some reason, need to specify summary explicitly. expect_output(ShowRegTable(lmer2, pDigits = 5, exp = FALSE), sprintf("%.5f", coef(lmerTest::summary(lmer2))[2,5])) - } - ## GLMM - glmer1 <- glmer(formula = y ~ trt + day + (1 | id), - data = koch, - family = poisson(link = "log")) - summary(glmer1) - ## Last rows correspond to fixed effects - ciGlmer1 <- tail(confint(glmer1), nrow(coef(summary(glmer1)))) + ## GLMM + glmer1 <- glmer(formula = y ~ trt + day + (1 | id), + data = koch, + family = poisson(link = "log")) + summary(glmer1) + ## Last rows correspond to fixed effects + ciGlmer1 <- tail(confint(glmer1), nrow(coef(summary(glmer1)))) - ## confint - ShowRegTable(glmer1, digits = 5, exp = TRUE) - expect_output(ShowRegTable(glmer1, digits = 5, exp = TRUE), - sprintf("%.5f, %.5f", - exp(ciGlmer1[2,1]), - exp(ciGlmer1[2,2]))) + ## confint + ShowRegTable(glmer1, digits = 5, exp = TRUE) + expect_output(ShowRegTable(glmer1, digits = 5, exp = TRUE), + sprintf("%.5f, %.5f", + exp(ciGlmer1[2,1]), + exp(ciGlmer1[2,2]))) - ## coef - expect_output(ShowRegTable(glmer1, digits = 5, exp = TRUE), - sprintf("%.5f", exp(coef(summary(glmer1)))[2,1])) + ## coef + expect_output(ShowRegTable(glmer1, digits = 5, exp = TRUE), + sprintf("%.5f", exp(coef(summary(glmer1)))[2,1])) + } }) From 22fd15bcceddff2a38b8070e4e5234eaa04b76da Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sun, 5 Nov 2017 16:52:59 -0500 Subject: [PATCH 41/44] Add test results --- cran-check.txt | 7 +++++-- tableone.Rcheck/tableone-Ex.Rout | 2 +- test-all.txt | 15 ++------------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/cran-check.txt b/cran-check.txt index 2467a8b..52ef56c 100644 --- a/cran-check.txt +++ b/cran-check.txt @@ -49,7 +49,10 @@ Maintainer: ‘Kazuki Yoshida ’ * checking for unstated dependencies in examples ... OK * checking installed files from ‘inst/doc’ ... OK * checking files in ‘vignettes’ ... OK -* checking examples ... OK +* checking examples ... NOTE +Examples with CPU or elapsed time > 5s + user system elapsed +svyCreateTableOne 7.565 0.349 10.198 * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... OK @@ -58,4 +61,4 @@ Maintainer: ‘Kazuki Yoshida ’ * checking re-building of vignette outputs ... OK * checking PDF version of manual ... OK * DONE -Status: OK +Status: 1 NOTE diff --git a/tableone.Rcheck/tableone-Ex.Rout b/tableone.Rcheck/tableone-Ex.Rout index 0e9727e..9cb008b 100644 --- a/tableone.Rcheck/tableone-Ex.Rout +++ b/tableone.Rcheck/tableone-Ex.Rout @@ -3324,7 +3324,7 @@ detaching ‘package:survey’, ‘package:survival’, ‘package:Matrix’, > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 6.538 0.228 7.029 0.005 0.004 +Time elapsed: 20.461 1.128 28.547 0.013 0.014 > grDevices::dev.off() null device 1 diff --git a/test-all.txt b/test-all.txt index 9b99b23..5f00f8e 100644 --- a/test-all.txt +++ b/test-all.txt @@ -2118,19 +2118,8 @@ day 0.96758 [0.96225, 0.97295] <0.001 (Intercept) 2.70219 [2.51140, 2.89298] <0.001 trt -0.36806 [-0.57681, -0.15930] 0.001 day -0.06464 [-0.07910, -0.05017] <0.001 -.. coef [confint] p -(Intercept) 2.70219 [2.51320, 2.89118] NA -trt -0.36806 [-0.57306, -0.16305] NA -day -0.06464 [-0.07905, -0.05022] NA -.. coef [confint] p -(Intercept) 2.70219 [2.51320, 2.89118] <0.001 -trt -0.36806 [-0.57306, -0.16305] 0.001 -day -0.06464 [-0.07905, -0.05022] <0.001 -... exp(coef) [confint] p -(Intercept) 2.82371 [2.31045, 3.43231] <0.001 -trt 0.82903 [0.70232, 0.97777] 0.026 -day 0.96758 [0.94787, 0.98762] 0.002 -.. +..### The lme4 version is 1.1-14 + Unit tests for svy* user functions: ................. Overall Missing n 450.01 From 3447c413dfc6ebc74f3e46e84cd7373f6b159fc5 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sun, 5 Nov 2017 17:03:07 -0500 Subject: [PATCH 42/44] Drop oldrel --- cran-comment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cran-comment.md b/cran-comment.md index 4d3c791..cdc7246 100644 --- a/cran-comment.md +++ b/cran-comment.md @@ -25,7 +25,7 @@ BUG FIXES ## Test environments * Local OS X 10.12.6, R 3.4.2 -* Ubuntu Linux on Travis-CI (oldrel, release, and devel) +* Ubuntu Linux on Travis-CI (release and devel) * win-builder (release and devel) From 0df398acec757caf271ced0a6e1b81452a2c4765 Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sun, 5 Nov 2017 17:05:01 -0500 Subject: [PATCH 43/44] Add testing under lme4 1.1-15 --- test-all.txt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test-all.txt b/test-all.txt index 5f00f8e..4235d2b 100644 --- a/test-all.txt +++ b/test-all.txt @@ -2118,8 +2118,20 @@ day 0.96758 [0.96225, 0.97295] <0.001 (Intercept) 2.70219 [2.51140, 2.89298] <0.001 trt -0.36806 [-0.57681, -0.15930] 0.001 day -0.06464 [-0.07910, -0.05017] <0.001 -..### The lme4 version is 1.1-14 - +..### The lme4 version is 1.1-15 + coef [confint] p +(Intercept) 2.70219 [2.51320, 2.89118] NA +trt -0.36806 [-0.57306, -0.16305] NA +day -0.06464 [-0.07905, -0.05022] NA +.. coef [confint] p +(Intercept) 2.70219 [2.51320, 2.89118] <0.001 +trt -0.36806 [-0.57306, -0.16305] 0.001 +day -0.06464 [-0.07905, -0.05022] <0.001 +... exp(coef) [confint] p +(Intercept) 2.82371 [2.31045, 3.43231] <0.001 +trt 0.82903 [0.70232, 0.97777] 0.026 +day 0.96758 [0.94787, 0.98762] 0.002 +.. Unit tests for svy* user functions: ................. Overall Missing n 450.01 From 9b4b4a212367359d05d58b3bbf07884a3130cb8c Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Sun, 5 Nov 2017 17:11:38 -0500 Subject: [PATCH 44/44] Add OK check status --- cran-check.txt | 7 ++----- tableone.Rcheck/tableone-Ex.Rout | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cran-check.txt b/cran-check.txt index 52ef56c..2467a8b 100644 --- a/cran-check.txt +++ b/cran-check.txt @@ -49,10 +49,7 @@ Maintainer: ‘Kazuki Yoshida ’ * checking for unstated dependencies in examples ... OK * checking installed files from ‘inst/doc’ ... OK * checking files in ‘vignettes’ ... OK -* checking examples ... NOTE -Examples with CPU or elapsed time > 5s - user system elapsed -svyCreateTableOne 7.565 0.349 10.198 +* checking examples ... OK * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... OK @@ -61,4 +58,4 @@ svyCreateTableOne 7.565 0.349 10.198 * checking re-building of vignette outputs ... OK * checking PDF version of manual ... OK * DONE -Status: 1 NOTE +Status: OK diff --git a/tableone.Rcheck/tableone-Ex.Rout b/tableone.Rcheck/tableone-Ex.Rout index 9cb008b..c8ce6bc 100644 --- a/tableone.Rcheck/tableone-Ex.Rout +++ b/tableone.Rcheck/tableone-Ex.Rout @@ -3324,7 +3324,7 @@ detaching ‘package:survey’, ‘package:survival’, ‘package:Matrix’, > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 20.461 1.128 28.547 0.013 0.014 +Time elapsed: 5.798 0.292 6.183 0.004 0.006 > grDevices::dev.off() null device 1