From 07febd4950095f0fc672dc4bcd67a47573d0f0f7 Mon Sep 17 00:00:00 2001 From: cbhurley Date: Thu, 29 Aug 2024 10:45:59 +0100 Subject: [PATCH] spelling --- DESCRIPTION | 2 +- tests/testthat/test-pair_methods.R | 107 ++++++++++++------------- tests/testthat/test-pair_scagnostics.R | 9 +-- 3 files changed, 55 insertions(+), 63 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3642aee..d6a9f26 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -6,7 +6,7 @@ Authors@R: person(given = "Catherine", family = "Hurley", email = "catherine.hurley@mu.ie", role = c("aut", "cre"))) Description: We provide a tidy data structure and visualisations for multiple or grouped variable correlations, general association measures scagnostics and other pairwise scores suitable for numerical, ordinal and nominal variables. - Supported measures include distance correlation, maximal information, ace correlation, Kendall's tau, and polychoric corrrelation. + Supported measures include distance correlation, maximal information, ace correlation, Kendall's tau, and polychoric correlation. License: MIT + file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) diff --git a/tests/testthat/test-pair_methods.R b/tests/testthat/test-pair_methods.R index 60d86b7..a5f29fb 100644 --- a/tests/testthat/test-pair_methods.R +++ b/tests/testthat/test-pair_methods.R @@ -1,5 +1,4 @@ - test_that("pair cor", { p <- pair_cor(iris[c(1,2,51,52,53),]) expect_s3_class(p, "pairwise") @@ -13,28 +12,25 @@ test_that("pair cancor", { }) test_that("pair dcor", { - if (requireNamespace("energy", quietly = TRUE)){ + skip_if_not(requireNamespace("energy", quietly = TRUE), message = "Package energy not available.") p <- pair_dcor(iris[1:4,]) expect_s3_class(p, "pairwise") expect_identical(dim(p), c(6L,6L)) - } }) test_that("pair mine", { - if (requireNamespace("minerva", quietly = TRUE)){ - p <- pair_mine(iris[c(1,2,51,52,53),]) - expect_s3_class(p, "pairwise") - expect_identical(dim(p), c(6L,6L)) - } + skip_if_not(requireNamespace("minerva", quietly = TRUE), message = "Package minerva not available.") + p <- pair_mine(iris[c(1,2,51,52,53),]) + expect_s3_class(p, "pairwise") + expect_identical(dim(p), c(6L,6L)) }) test_that("pair nmi", { - if (requireNamespace("linkspotter", quietly = TRUE)){ - p <- pair_nmi(iris[1:4,]) - expect_s3_class(p, "pairwise") - expect_identical(dim(p), c(10L,6L)) - } + skip_if_not(requireNamespace("linkspotter", quietly = TRUE), message = "Package linkspotter not available.") + p <- pair_nmi(iris[1:4,]) + expect_s3_class(p, "pairwise") + expect_identical(dim(p), c(10L,6L)) }) test_that("pair polychor", { @@ -54,36 +50,36 @@ test_that("pair polyserial", { }) test_that("pair tau", { - if (requireNamespace("DescTools", quietly = TRUE)){ - iris1 <- iris[c(1,2,53,55),] - iris1$Sepal.Length <- cut(iris1$Sepal.Length,2) - p <- pair_tauB(droplevels(iris1)) - expect_s3_class(p, "pairwise") - expect_identical(dim(p), c(1L,6L)) - p <- pair_tauA(droplevels(iris1)) - expect_s3_class(p, "pairwise") - expect_identical(dim(p), c(1L,6L)) - p <- pair_tauC(droplevels(iris1)) - expect_s3_class(p, "pairwise") - expect_identical(dim(p), c(1L,6L)) - p <- pair_tauW(droplevels(iris1)) - expect_s3_class(p, "pairwise") - expect_identical(dim(p), c(1L,6L)) - } + skip_if_not(requireNamespace("DescTools", quietly = TRUE), message = "Package DescTools not available.") + iris1 <- iris[c(1,2,53,55),] + iris1$Sepal.Length <- cut(iris1$Sepal.Length,2) + iris1 <- droplevels(iris1) + p <- pair_tauB(iris1) + expect_s3_class(p, "pairwise") + expect_identical(dim(p), c(1L,6L)) + p <- pair_tauA(iris1) + expect_s3_class(p, "pairwise") + expect_identical(dim(p), c(1L,6L)) + p <- pair_tauC(iris1) + expect_s3_class(p, "pairwise") + expect_identical(dim(p), c(1L,6L)) + p <- pair_tauW(iris1) + expect_s3_class(p, "pairwise") + expect_identical(dim(p), c(1L,6L)) }) test_that("pair uncertainty", { - if (requireNamespace("DescTools", quietly = TRUE)){ - iris1 <- iris[c(1,2,53,55),] - iris1$Sepal.Length <- cut(iris1$Sepal.Length,2) - p <- pair_uncertainty(droplevels(iris1)) - expect_s3_class(p, "pairwise") - expect_identical(dim(p), c(1L,6L)) - } + skip_if_not(requireNamespace("DescTools", quietly = TRUE), message = "Package DescTools not available.") + iris1 <- iris[c(1,2,53,55),] + iris1$Sepal.Length <- cut(iris1$Sepal.Length,2) + p <- pair_uncertainty(droplevels(iris1)) + expect_s3_class(p, "pairwise") + expect_identical(dim(p), c(1L,6L)) }) test_that("pair gkTau", { + skip_if_not(requireNamespace("DescTools", quietly = TRUE), message = "Package DescTools not available.") iris1 <- iris[c(1,2,53,55),] iris1$Sepal.Length <- cut(iris1$Sepal.Length,2) p <- pair_gkTau(droplevels(iris1)) @@ -93,37 +89,34 @@ test_that("pair gkTau", { test_that("pair gkGamma", { - if (requireNamespace("DescTools", quietly = TRUE)){ - iris1 <- iris[c(1,2,53,55),] - iris1$Sepal.Length <- cut(iris1$Sepal.Length,2) - p <- pair_gkGamma(droplevels(iris1)) - expect_s3_class(p, "pairwise") - expect_identical(dim(p), c(1L,6L)) - } + skip_if_not(requireNamespace("DescTools", quietly = TRUE), message = "Package DescTools not available.") + iris1 <- iris[c(1,2,53,55),] + iris1$Sepal.Length <- cut(iris1$Sepal.Length,2) + p <- pair_gkGamma(droplevels(iris1)) + expect_s3_class(p, "pairwise") + expect_identical(dim(p), c(1L,6L)) }) test_that("pair chi", { - if (requireNamespace("DescTools", quietly = TRUE)){ - iris1 <- iris[c(1,2,53,55),] - iris1$Sepal.Length <- cut(iris1$Sepal.Length,2) - p <- pair_chi(droplevels(iris1)) - expect_s3_class(p, "pairwise") - expect_identical(dim(p), c(1L,6L)) - } + skip_if_not(requireNamespace("DescTools", quietly = TRUE), message = "Package DescTools not available.") + iris1 <- iris[c(1,2,53,55),] + iris1$Sepal.Length <- cut(iris1$Sepal.Length,2) + p <- pair_chi(droplevels(iris1)) + expect_s3_class(p, "pairwise") + expect_identical(dim(p), c(1L,6L)) }) test_that("pair ace", { - if (requireNamespace("acepack", quietly = TRUE)){ - p <- pair_ace(iris[c(1,2,53,55),]) - expect_s3_class(p, "pairwise") - expect_identical(dim(p), c(10L,6L)) - } + skip_if_not(requireNamespace("acepack", quietly = TRUE), message = "Package acepack not available.") + p <- pair_ace(iris[c(1,2,53,55),]) + expect_s3_class(p, "pairwise") + expect_identical(dim(p), c(10L,6L)) }) test_that("pair multi", { - p <- pairwise_multi(iris) + p <- pairwise_multi(iris, scores=c("pair_cor", "pair_cancor")) expect_s3_class(p, "pairwise") - expect_identical(dim(p), c(54L,6L)) + expect_identical(dim(p), c(22L,6L)) }) diff --git a/tests/testthat/test-pair_scagnostics.R b/tests/testthat/test-pair_scagnostics.R index 297c7ea..edde0a4 100644 --- a/tests/testthat/test-pair_scagnostics.R +++ b/tests/testthat/test-pair_scagnostics.R @@ -1,8 +1,7 @@ test_that("pair scagnostics", { - if (requireNamespace("scagnostics", quietly = TRUE)){ - p <- pair_scagnostics(iris[c(1,2,53,55),], c("Clumpy", "Striated")) - expect_s3_class(p, "pairwise") - expect_identical(dim(p), c(12L,6L)) - } + skip_if_not(requireNamespace("scagnostics", quietly = TRUE), message = "Package scagnostics not available.") + p <- pair_scagnostics(iris[c(1,2,53,55),], c("Clumpy", "Striated")) + expect_s3_class(p, "pairwise") + expect_identical(dim(p), c(12L,6L)) }) \ No newline at end of file