tests/testthat/test-drscatterplot_and_goodnessoffit.R

context("Dimension Reduction Scatterplot and GoodnessOfFit")

data(hbatwithsplits, package = "flipExampleData")
# numerical and factor inputs
input.data <- hbatwithsplits[, c("x4", "x5", "x6", "x7", "x8", "x9", "x10", "x11", "x12")]
input.data$x4[1:5] <- NA
subset <- hbatwithsplits$x3 != "Large (500+)"

# distance matrices
middle.east <- c("", "Al-Qaida", "Egypt", "Hamas", "Hezbollah", "Iran", "Iraq",
                  "ISIS", "Israel", "Palestinian Authority", "Saudi Arabia", "Syria",
                  "Turkey", "United States", "Al-Qaida", "0", "3", "2", "3", "2",
                  "3", "3", "3", "3", "3", "3", "3", "3", "Egypt", "3", "0", "3",
                  "3", "2", "1", "3", "1", "2", "1", "3", "3", "1", "Hamas", "2",
                  "3", "0", "2", "2", "2", "3", "3", "2", "2", "3", "1", "3", "Hezbollah",
                  "3", "3", "2", "0", "1", "1", "3", "3", "2", "3", "1", "2", "3",
                  "Iran", "2", "2", "2", "1", "0", "1", "3", "3", "2", "3", "1",
                  "3", "3", "Iraq", "3", "1", "2", "1", "1", "0", "3", "3", "1",
                  "3", "1", "3", "1", "ISIS", "3", "3", "3", "3", "3", "3", "0",
                  "3", "3", "3", "3", "3", "3", "Israel", "3", "1", "3", "3", "3",
                  "3", "3", "0", "3", "2", "3", "2", "1", "Palestinian Authority",
                  "3", "2", "2", "2", "2", "1", "3", "3", "0", "1", "2", "1", "2",
                  "Saudi Arabia", "3", "1", "2", "3", "3", "3", "3", "2", "1",
                  "0", "3", "2", "1", "Syria", "3", "3", "3", "1", "1", "1", "3",
                  "3", "2", "3", "0", "1", "3", "Turkey", "3", "3", "1", "2", "3",
                  "3", "3", "2", "1", "2", "1", "0", "2", "United States", "3",
                  "1", "3", "3", "3", "1", "3", "1", "2", "1", "3", "2", "0")
middle.east <- matrix(middle.east, 14, 14)

data(breakfast.dissimilarities, package = "flipExampleData")
breakfast = breakfast.dissimilarities[[1]]


test_that("Dimension Reduction Scatterplot and GoodnessOfFit: data.frame", {
    for (algo in c("t-SNE", "MDS - Metric", "MDS - Non-metric", "PCA")) {
        for (groups in list(hbatwithsplits$x1, hbatwithsplits$x19, NULL)) {
            for (norm in c(TRUE, FALSE)) {
                expect_error(d <- DimensionReductionScatterplot(data = input.data, data.groups = groups, algorithm = algo,
                                                           perplexity = 10, normalization = norm, subset = subset), NA)
                expect_equal(attr(d, "ChartType"), "X Y Scatter")
                expect_equal(ncol(attr(d, "ChartData")), if (is.null(groups)) 2 else 3)
                expect_equal(names(attr(attr(d, "ChartData"), "scatter.variable.indices")),
                             c("x", "y", "sizes", "colors"))
                expect_error(GoodnessOfFitPlot(d, max.points = 100), NA)
                expect_error(fitted(d), NA)
            }
        }
    }
})

test_that("Dimension Reduction Scatterplot and GoodnessOfFit: raw matrix", {
    for (algo in c("t-SNE", "MDS - Metric", "MDS - Non-metric")) {
        expect_error(d <- DimensionReductionScatterplot(table = middle.east, algorithm = algo, raw.table = TRUE,
                                                        perplexity = 3), NA)
        expect_error(GoodnessOfFitPlot(d, max.points = 100), NA)
        expect_error(fitted(d), NA)
    }
})

test_that("Dimension Reduction Scatterplot and GoodnessOfFit: distance matrix (class = dist)", {
    for (algo in c("t-SNE", "MDS - Metric", "MDS - Non-metric")) {
        expect_error(d <- DimensionReductionScatterplot(table = breakfast, algorithm = algo, raw.table = FALSE,
                                                        perplexity = 3), NA)
        expect_error(GoodnessOfFitPlot(d, max.points = 100), NA)
        expect_error(fitted(d), NA)
    }
})

data(pcaPhoneTestData, package = "flipExampleData")
phone.data <- pcaPhoneTestData$data.set.original # Most cases do not have missing observations (named "q23" in SPSS file)
dm <- DistanceMatrix(phone.data)

test_that("Dimension Reduction Scatterplot and GoodnessOfFit: distance matrix (class = DistanceMatrix)", {
    for (algo in c("t-SNE", "MDS - Metric", "MDS - Non-metric")) {
        expect_error(d <- DimensionReductionScatterplot(table = dm, algorithm = algo, raw.table = FALSE,
                                                        perplexity = 3), NA)
        expect_error(GoodnessOfFitPlot(d, max.points = 100), NA)
        expect_error(fitted(d), NA)
    }
})

text.matrix <- structure(c(-0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, 3.9605901719067, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, 4.90098029409803,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, 3.9605901719067, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    4.90098029409803, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    3.9605901719067, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    4.90098029409803, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, 1.8881372801234,
    2.13896315973249, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, 3.9605901719067, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, 4.90098029409803, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, 3.9605901719067,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, 3.9605901719067, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, 1.8881372801234,
    2.13896315973249, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    3.00326619585032, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, 3.9605901719067, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, 3.39405477904191,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, 3.9605901719067, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    3.00326619585032, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, 3.9605901719067,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    4.90098029409803, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, 1.8881372801234,
    2.13896315973249, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, 4.90098029409803,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, 3.9605901719067, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, 2.7116307227332,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, 3.9605901719067, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, 1.8881372801234,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, 3.9605901719067,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, 2.7116307227332,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, 3.9605901719067,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    3.9605901719067, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, 4.90098029409803, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, 3.9605901719067,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, 4.90098029409803, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, 3.9605901719067, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, 4.90098029409803, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, 1.8881372801234, 2.13896315973249, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    3.9605901719067, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, 4.90098029409803,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, 3.9605901719067, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, 3.9605901719067,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, 1.8881372801234, 2.13896315973249, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, 3.00326619585032, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    3.9605901719067, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, 3.39405477904191, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    3.9605901719067, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, 3.00326619585032, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, 3.9605901719067, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, 4.90098029409803, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, 1.8881372801234, 2.13896315973249, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, 4.90098029409803, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    3.9605901719067, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, 2.7116307227332, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    3.9605901719067, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, 1.8881372801234, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, 3.9605901719067, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, 2.7116307227332, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, 3.9605901719067, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, 3.39405477904191, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, 3.9605901719067, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, 3.9605901719067, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, 7.00140042014005, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    3.9605901719067, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, 7.00140042014005, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    2.13896315973249, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, 7.00140042014005,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, 3.9605901719067, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    7.00140042014005, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, 3.9605901719067,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, 3.9605901719067, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, 1.8881372801234,
    2.13896315973249, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    3.00326619585032, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, 3.9605901719067, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, 3.39405477904191,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, 3.9605901719067, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, 3.9605901719067,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, 7.00140042014005, 1.8881372801234,
    2.13896315973249, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, -0.361550763031094,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, 7.00140042014005, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.519237752033936,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, 3.9605901719067, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, 2.7116307227332,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, 3.9605901719067, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, 1.8881372801234,
    -0.458349248514106, -0.361550763031094, -0.326441977809817, -0.288855725875908,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, 3.9605901719067,
    -0.247536885744169, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.519237752033936, -0.458349248514106, 2.7116307227332,
    -0.326441977809817, -0.288855725875908, -0.247536885744169, 3.9605901719067,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.247536885744169,
    -0.247536885744169, -0.247536885744169, -0.247536885744169, -0.200040012004001,
    -0.200040012004001, -0.200040012004001, -0.200040012004001, -0.200040012004001,
    -0.200040012004001, -0.140028008402801, -0.140028008402801, -0.140028008402801,
    -0.140028008402801, -0.140028008402801, -0.140028008402801), .Dim = c(30L,
    51L), .Dimnames = list(Terms = c("favorite", "few", "feel", "white",
    "nose", "apple, cream, streudels", "bad, dont", "bee, stings",
    "bells, doorbells, noodles, schnitzel, sleigh", "blue, dresses, girls, sashes, satin",
    "bright, kettles, mittens, warm, woolen", "eyelashes, snowflakes, stay",
    "fly, geese, moon, wild, wings", "kittens, raindrops, whiskers",
    "melt, silver, winters", "packages, paper, strings, tied", "remember, simply",
    "sad", "bites, dog", "brown", "colored, crisp, ponies", "copper",
    "roses", "springs", "bights, dawg", "brun", "cawpper", "coloured, krisp, ponees",
    "favourite", "sprang, whit"), Docs = c("1", "2", "3", "4", "5",
    "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16",
    "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27",
    "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38",
    "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49",
    "50", "51")), "`scaled:center`" = c(favorite = 0.215686274509804,
    few = 0.176470588235294, feel = 0.117647058823529, white = 0.0980392156862745,
    nose = 0.0784313725490196, `apple, cream, streudels` = 0.0588235294117647,
    `bad, dont` = 0.0588235294117647, `bee, stings` = 0.0588235294117647,
    `bells, doorbells, noodles, schnitzel, sleigh` = 0.0588235294117647,
    `blue, dresses, girls, sashes, satin` = 0.0588235294117647, `bright, kettles, mittens, warm, woolen` = 0.0588235294117647,
    `eyelashes, snowflakes, stay` = 0.0588235294117647, `fly, geese, moon, wild, wings` = 0.0588235294117647,
    `kittens, raindrops, whiskers` = 0.0588235294117647, `melt, silver, winters` = 0.0588235294117647,
    `packages, paper, strings, tied` = 0.0588235294117647, `remember, simply` = 0.0588235294117647,
    sad = 0.0588235294117647, `bites, dog` = 0.0392156862745098,
    brown = 0.0392156862745098, `colored, crisp, ponies` = 0.0392156862745098,
    copper = 0.0392156862745098, roses = 0.0392156862745098, springs = 0.0392156862745098,
    `bights, dawg` = 0.0196078431372549, brun = 0.0196078431372549,
    cawpper = 0.0196078431372549, `coloured, krisp, ponees` = 0.0196078431372549,
    favourite = 0.0196078431372549, `sprang, whit` = 0.0196078431372549
    ), "`scaled:scale`" = c(favorite = 0.415390201627149, few = 0.385013368751849,
    feel = 0.325395686727984, white = 0.300326619585032, nose = 0.271524382323353,
    `apple, cream, streudels` = 0.237635410314402, `bad, dont` = 0.237635410314402,
    `bee, stings` = 0.237635410314402, `bells, doorbells, noodles, schnitzel, sleigh` = 0.237635410314402,
    `blue, dresses, girls, sashes, satin` = 0.237635410314402, `bright, kettles, mittens, warm, woolen` = 0.237635410314402,
    `eyelashes, snowflakes, stay` = 0.237635410314402, `fly, geese, moon, wild, wings` = 0.237635410314402,
    `kittens, raindrops, whiskers` = 0.237635410314402, `melt, silver, winters` = 0.237635410314402,
    `packages, paper, strings, tied` = 0.237635410314402, `remember, simply` = 0.237635410314402,
    sad = 0.237635410314402, `bites, dog` = 0.196039211763921, brown = 0.196039211763921,
    `colored, crisp, ponies` = 0.196039211763921, copper = 0.196039211763921,
    roses = 0.196039211763921, springs = 0.196039211763921, `bights, dawg` = 0.140028008402801,
    brun = 0.140028008402801, cawpper = 0.140028008402801, `coloured, krisp, ponees` = 0.140028008402801,
    favourite = 0.140028008402801, `sprang, whit` = 0.140028008402801
    ))

test_that("Dimension Reduction Scatterplot works with matrices",
{
    expect_error(DimensionReductionScatterplot(data = text.matrix, algorithm = "MDS - Non-metric"), NA)
})


test_that("Dimension Reduction Scatterplot gives informative messages", {
    captured.warning <- capture_warnings(PrincipalComponentsAnalysis(text.matrix[, 1:2],
                                                                     select.n.rule = "Kaiser rule",
                                                                     eigen.min = 1.1,
                                                                     print.type = "2D Scatterplot"))
    expected.warning <- capture_warnings(throwWarningAbout2DScatterplotNotPossible(select.n.rule = "Kaiser rule",
                                                                                   eigenvalues = c(1.1, 0.9),
                                                                                   eigen.min = 1L))
    expect_setequal(captured.warning, expected.warning)
    captured.warning <- capture_warnings(PrincipalComponentsAnalysis(text.matrix[, 1:2],
                                                                     select.n.rule = "Number of components",
                                                                     n.factors = 1L,
                                                                     print.type = "2D Scatterplot"))
    expected.warning <- capture_warnings(throwWarningAbout2DScatterplotNotPossible(select.n.rule = "Number of components"))
    expect_setequal(captured.warning, expected.warning)
    captured.warning <- capture_warnings(pca.out <- PrincipalComponentsAnalysis(text.matrix[, 1:5],
                                                                                select.n.rule = "Eigenvalues over",
                                                                                eigen.min = 1.1,
                                                                                print.type = "2D Scatterplot"))
    expected.warning <- capture_warnings(throwWarningAbout2DScatterplotNotPossible(select.n.rule = "Eigenvalues over", eigenvalues = pca.out$values, eigen.min = 1.1))
    expect_setequal(captured.warning, expected.warning)
})
Displayr/flipDimensionReduction documentation built on March 2, 2024, 3:50 a.m.