Skip to content

Commit c0e423f

Browse files
committed
- let nonconvergence warnings be caught despite future
- turn off OS X on travis for now
1 parent ee00a90 commit c0e423f

File tree

5 files changed

+30
-14
lines changed

5 files changed

+30
-14
lines changed

.travis.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ matrix:
5454
- pander
5555
- minpack.lm
5656
- StanHeaders
57-
- os: osx
58-
osx_image: xcode9.2
59-
- os: osx
60-
osx_image: xcode7.3
61-
r_build_args: '--no-build-vignettes'
62-
r_check_args: '--ignore-vignettes --no-examples'
57+
# - os: osx
58+
# osx_image: xcode9.2
59+
# - os: osx
60+
# osx_image: xcode7.3
61+
# r_build_args: '--no-build-vignettes'
62+
# r_check_args: '--ignore-vignettes --no-examples'
6363

6464
addons:
6565
apt:
@@ -74,4 +74,3 @@ after_success:
7474

7575
repos:
7676
CRAN: https://cloud.r-project.org
77-
ropensci: http://packages.ropensci.org

R/misc.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ md.pattern <- function(x, plot = FALSE)
3434
mpat <- sortR[!duplicated(sortR), ]
3535
}
3636
if (all(!is.na(x))) {
37-
cat(" /\\ /\\\n{ `---' }\n{ O O }\n==> V <==")
38-
cat(" No need for mice. This data set is completely observed.\n")
39-
cat(" \\ \\|/ /\n `-----'\n\n")
37+
message(" /\\ /\\\n{ `---' }\n{ O O }\n==> V <==")
38+
message(" No need for mice. This data set is completely observed.\n")
39+
message(" \\ \\|/ /\n `-----'\n\n")
4040
mpat <- t(as.matrix(mpat, byrow = TRUE))
4141
rownames(mpat) <- table(pat)
4242
}
@@ -73,7 +73,7 @@ md_pattern <- function(data, omit_complete = TRUE, min_freq = 0.01) {
7373
# mice::md.pattern coerces character/factor to NA
7474
data[[i]] <- as.numeric(as.factor(data[[i]]))
7575
}
76-
md_pattern <- md.pattern(data, plot = FALSE)
76+
md_pattern <- suppressMessages(md.pattern(data, plot = FALSE))
7777
n_miss <- rownames(md_pattern)
7878
if (is.null(n_miss)) {
7979
n_miss <- rep(0, nrow(md_pattern))
@@ -84,7 +84,7 @@ md_pattern <- function(data, omit_complete = TRUE, min_freq = 0.01) {
8484
missing_by_var <- md_pattern[nrow(md_pattern), ]
8585
md_pattern <- md_pattern[, missing_by_var > 0]
8686
}
87-
md_pattern <- tibble::as.tibble(md_pattern)
87+
md_pattern <- tibble::as_tibble(md_pattern)
8888
stopifnot(!exists("n_miss", md_pattern))
8989
md_pattern$n_miss <- as.numeric(n_miss)
9090
md_pattern$n_miss[nrow(md_pattern)] <-

R/reliability.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ compute_reliabilities <- function(results, survey_repetition = "single") {
4242
survey_repetition, ci = TRUE)
4343
}, error = function(e) {
4444
tryCatch({
45+
warning("Reliability CIs could not be computed for ", var)
46+
warning(conditionMessage(e))
4547
compute_appropriate_reliability(var, scale_info,
4648
items,
4749
survey_repetition, ci = FALSE)
4850
}, error = function(e) {
49-
warning(e)
51+
warning("Reliability could not be computed for ", var)
52+
warning(conditionMessage(e))
5053
NULL
5154
})
5255

tests/testthat/test_misc.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@ test_that("Missing values are computed properly", {
3131
expect_silent(mdp <- md_pattern(nhanes))
3232
expect_equal(mdp$n_miss[1], 27)
3333
expect_equal(nrow(mdp), 6)
34+
})
35+
36+
test_that("Missing values are computed properly, omit complete", {
3437
expect_silent(mdp <- md_pattern(nhanes,
3538
omit_complete = FALSE, min_freq = 0.2))
3639
expect_equal(mdp$n_miss[1], 27)
3740
expect_equal(mdp$n_miss[4], 5)
3841
expect_equal(nrow(mdp), 4)
42+
})
43+
44+
test_that("Missing values are computed properly, degenerate cases", {
3945
expect_message(mdp <- md_pattern(data.frame()), "No missing")
4046
expect_message(mdp <- md_pattern(data.frame(x = 1, y = 1)), "No missing")
4147
expect_null(mdp)

tests/testthat/test_reliability.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test_that("Internal consistencies can be computed", {
66
library(dplyr)
77
bfi <- bfi %>% select(-starts_with("BFIK_extra"),
88
-starts_with("BFIK_neuro"),
9-
-starts_with("BFIK_consc"))
9+
-starts_with("BFIK_open"))
1010
expect_silent(rels <- compute_reliabilities(bfi))
1111
expect_equal(length(rels), 2)
1212
expect_equal(length(rels$BFIK_agree), 1)
@@ -84,3 +84,11 @@ test_that("Multilevel reliabilities can be computed", {
8484

8585
expect_equal(round(rels$BFIK_agree$multilevel_reliability$Rcn,3), 0)
8686
})
87+
88+
test_that("Nonconvergence warnings are caught", {
89+
data("bfi", package = "codebook")
90+
library(dplyr)
91+
bfi <- bfi %>% select(starts_with("BFIK_open"))
92+
expect_warning(compute_reliabilities(bfi),
93+
"Reliability CIs could not be computed for BFIK_open")
94+
})

0 commit comments

Comments
 (0)