Skip to content

Commit

Permalink
Merge branch 'rc-0.7.1'
Browse files Browse the repository at this point in the history
* Fix unit tests to work on SPARC
* Correct vignette entry name
  • Loading branch information
kaz-yos committed Aug 12, 2015
2 parents 7031ed0 + 27273ab commit f01454d
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 24 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: tableone
Type: Package
Title: Create "Table 1" to Describe Baseline Characteristics
Version: 0.7.0
Date: 2015-08-10
Version: 0.7.1
Date: 2015-08-11
Author: Kazuki Yoshida, Justin Bohn.
Maintainer: Kazuki Yoshida <[email protected]>
Description: Creates "Table 1", i.e., description of baseline patient
Expand Down
11 changes: 11 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
tableone 0.7.1 (2015-08-11)
----------------------------------------------------------------

BUG FIXES

* Solve problems with unit testing on the sparc architecture
without extended-precision arithmetic support.

* Fix title for second vignette.


tableone 0.7.0 (2015-08-10)
----------------------------------------------------------------

Expand Down
4 changes: 4 additions & 0 deletions R/modules-smd.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ StdDiff <- function(variable, group, binary = FALSE, na.rm = TRUE) {

out <- meanDiffs / sqrt(varMeans)

## This lower.tri() approach is actually giving 2vs1, 3vs1, etc
## opposite of stated 1vs2, 1vs3. Only correct if abs() is used.
abs(out[lower.tri(out)])
}

Expand Down Expand Up @@ -277,6 +279,8 @@ svyStdDiff <- function(varName, groupName, design, binary = FALSE, na.rm = TRUE)

out <- meanDiffs / sqrt(varMeans)

## This lower.tri() approach is actually giving 2vs1, 3vs1, etc
## opposite of stated 1vs2, 1vs3. Only correct if abs() is used.
abs(out[lower.tri(out)])
}

Expand Down
8 changes: 5 additions & 3 deletions cran-check.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* using option ‘--as-cran’
* checking for file ‘tableone/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘tableone’ version ‘0.7.0
* checking CRAN incoming feasibility ... Note_to_CRAN_maintainers
* this is package ‘tableone’ version ‘0.7.1
* checking CRAN incoming feasibility ... NOTE
Maintainer: ‘Kazuki Yoshida <[email protected]>’

Days since last update: 1
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
Expand Down Expand Up @@ -62,4 +64,4 @@ Maintainer: ‘Kazuki Yoshida <[email protected]>’
* checking re-building of vignette outputs ... OK
* checking PDF version of manual ... OK
* DONE
Status: OK
Status: 1 NOTE
14 changes: 7 additions & 7 deletions cran-comment.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
## What's new
* Weighted data support
* Standardized mean difference support
* Solve problems with unit testing on the sparc architecture without extended-precision arithmetic support at request of a CRAN maintainer.
* Fix title for second vignette.

## Test environments
* Local OS X 10.10.4, R 3.2.1; R-devel (2015-08-06 r68871)
* Local OS X 10.10.4, R 3.2.1 (--disable-long-double) and R develop
* Ubuntu Linux (on Travis-CI), R 3.2.1
* winb-builder (devel and release)
* win-builder (devel and release)

## R CMD check results
* ERRORs: None
* WARNINGs: None
* NOTEs:
- Package author e-mail confirmation.
- "No repository set, so cyclic dependency check skipped" on R 3.2.1 on win-builder (not a package problem)
- Author e-mail check
- Short interval from last submission (0.7.0 on 2015-08-10)

## Downstream dependencies
RcmdrPlugin.EZR GUI frontend: Manually examined "Summary table of sample characteristics" for compatibility; EZR author also examined compatibility.
RcmdrPlugin.EZR GUI frontend: No change was made to APIs.
2 changes: 1 addition & 1 deletion tableone.Rcheck/tableone-Ex.Rout
Original file line number Diff line number Diff line change
Expand Up @@ -3273,7 +3273,7 @@ detaching ‘package:survey’, ‘package:grid’
> ###
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
Time elapsed: 4.533 0.144 4.746 0.005 0.007
Time elapsed: 3.646 0.098 3.78 0.005 0.006
> grDevices::dev.off()
null device
1
Expand Down
32 changes: 22 additions & 10 deletions tests/testthat/test-modules-smd.R
Original file line number Diff line number Diff line change
Expand Up @@ -433,19 +433,21 @@ test_that("decent results are returned for anomalous/difficult data", {
## NaN due to division by zero variance
by(nhanes$onlyOne, nhanes$RIAGENDR, summary)
expect_equal(StdDiff(nhanes$onlyOne, group = nhanes$RIAGENDR), NaN)
## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0
## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0; defined NaN in (svy)StdDiffMulti
table(nhanes$onlyOne, nhanes$RIAGENDR)
expect_equal(StdDiffMulti(nhanes$onlyOne, group = nhanes$RIAGENDR), NaN)
## When weighted problematic
means1 <- svyby(~ onlyOne, by = ~ RIAGENDR, nhanesSvy, FUN = svymean)[,2]
vars1 <- svyby(~ onlyOne, by = ~ RIAGENDR, nhanesSvy, FUN = svyvar)[,2]
## Very small difference is inflated by even smaller variance
## on sparc-sun-solaris sign was opposite; abs() solves this issue
## as svyStdDiff() uses abs() internally
expect_equal(svyStdDiff("onlyOne", "RIAGENDR", nhanesSvy),
(means1[1] - means1[2]) / sqrt(sum(vars1) / 2))
abs((means1[1] - means1[2]) / sqrt(sum(vars1) / 2)))
## NaN should be the case, but it's not, but it's consistent with survey
## expect_equal(svyStdDiff("onlyOne", "RIAGENDR", nhanesSvy), NaN)

## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0
## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0; defined NaN in (svy)StdDiffMulti
## No error even with a single level variable (constant) as redundant
## level drop from table occurs only when 2+ levels are present.
## If any group has more than 2 levels, then strata-by-level table
Expand All @@ -456,7 +458,7 @@ test_that("decent results are returned for anomalous/difficult data", {
## NaN due to division by zero variance
by(nhanes$onlyOne, nhanes$race, summary)
expect_equal(StdDiff(nhanes$onlyOne, group = nhanes$race), rep(NaN, 6))
## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0
## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0; defined NaN in (svy)StdDiffMulti
expect_equal(StdDiffMulti(nhanes$onlyOne, group = nhanes$race), rep(NaN, 6))
## When weighted problematic; not in this case??
means2 <- svyby(~ onlyOne, by = ~ race, nhanesSvy, FUN = svymean)[,2]
Expand All @@ -467,9 +469,19 @@ test_that("decent results are returned for anomalous/difficult data", {
(means2[2] - means2[3]) / sqrt((vars2[2] + vars2[3]) / 2),
(means2[2] - means2[4]) / sqrt((vars2[2] + vars2[4]) / 2),
(means2[3] - means2[4]) / sqrt((vars2[3] + vars2[4]) / 2))
expect_equal(svyStdDiff("onlyOne", "race", nhanesSvy), meanDiffs2)
expect_equal(svyStdDiff("onlyOne", "race", nhanesSvy), rep(NaN, 6))
## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0
## on sparc-sun-solaris sign was opposite; abs() solves this issue
## as svyStdDiff() uses abs() internally
expect_equal(svyStdDiff("onlyOne", "race", nhanesSvy), abs(meanDiffs2))
## This one is rep(NaN,6) for most platforms except for sparc-sun-solaris
## where ./configure --disable-long-double is used.
## capabilities()["long.double"] was added in R 3.1.3.
## As of 2015-08-11, only r-oldrel-windows-ix86+x86_64 is R 3.1.3.
## https://cran.r-project.org/web/checks/check_results_tableone.html
if (capabilities()["long.double"]) {
## Cannot run on sparc-sun-solaris due to lack of extended precision arithmetic
expect_equal(svyStdDiff("onlyOne", "race", nhanesSvy), rep(NaN, 6))
}
## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0; defined NaN in (svy)StdDiffMulti
expect_equal(svyStdDiffMulti("onlyOne", "race", nhanesSvy), rep(NaN, 6))


Expand All @@ -490,15 +502,15 @@ test_that("decent results are returned for anomalous/difficult data", {
expect_warning(expect_equal(svyStdDiff("onlyNa", "RIAGENDR", nhanesSvy),
as.numeric(NA)),
"onlyNa has only NA's in at least one stratum. na.rm turned off.")
## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0
## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0; defined NaN in (svy)StdDiffMulti
expect_warning(expect_equal(svyStdDiffMulti("onlyNa", "RIAGENDR", nhanesSvy), NaN),
"onlyNa has only NA's in all strata. Regarding NA as a level.")

## Four groups (six contrasts)
## NaN due to division by zero variance
expect_warning(expect_equal(StdDiff(nhanes$onlyNa, group = nhanes$race), rep(NaN, 6)),
"Variable has only NA's in at least one stratum. na.rm turned off.")
## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0
## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0; defined NaN in (svy)StdDiffMulti
expect_warning(expect_equal(StdDiffMulti(nhanes$onlyNa, group = nhanes$race), rep(NaN, 6)),
"Variable has only NA's in all strata. Regarding NA as a level.")
## When weighted problematic; not in this case??
Expand All @@ -514,7 +526,7 @@ test_that("decent results are returned for anomalous/difficult data", {
"onlyNa has only NA's in at least one stratum. na.rm turned off.")
expect_warning(expect_equal(svyStdDiff("onlyNa", "race", nhanesSvy), rep(NaN, 6)),
"onlyNa has only NA's in at least one stratum. na.rm turned off.")
## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0
## 0 because [0]^- = 0, and [1]^T [0]^-1 [1] = 0; defined NaN in (svy)StdDiffMulti
expect_warning(expect_equal(svyStdDiffMulti("onlyNa", "race", nhanesSvy), rep(NaN, 6)),
"onlyNa has only NA's in all strata. Regarding NA as a level.")

Expand Down
2 changes: 1 addition & 1 deletion vignettes/smd.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author: "Kazuki Yoshida"
date: "2015-08-07"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Introduction to tableone}
%\VignetteIndexEntry{Using standardized mean differences}
%\VignetteEngine{knitr::rmarkdown}
\usepackage[utf8]{inputenc}
---
Expand Down

0 comments on commit f01454d

Please sign in to comment.