| 1 |
skip_on_cran() |
| 2 |
|
| 3 |
skip_if_not_installed("modeltests") |
| 4 |
library(modeltests) |
| 5 |
|
| 6 |
skip_if_not_installed("cluster") |
| 7 |
suppressPackageStartupMessages(library(cluster)) |
| 8 |
|
| 9 |
skip_if_not_installed("modeldata") |
| 10 |
library(modeldata) |
| 11 |
data(hpc_data) |
| 12 |
|
| 13 |
x <- hpc_data[1:300, 2:5] |
| 14 |
fit <- pam(x, k = 3) |
| 15 |
|
| 16 |
test_that("pam tidier arguments", { |
| 17 |
check_arguments(tidy.pam) |
| 18 |
check_arguments(glance.pam) |
| 19 |
check_arguments(augment.pam) |
| 20 |
}) |
| 21 |
|
| 22 |
test_that("tidy.pam", { |
| 23 |
td <- tidy(fit) |
| 24 |
|
| 25 |
# includes names of input data columns, so strict = FALSE |
| 26 |
check_tidy_output(td, strict = FALSE) |
| 27 |
check_dims(td, 3, 11) |
| 28 |
}) |
| 29 |
|
| 30 |
test_that("glance.pam", { |
| 31 |
gl <- glance(fit) |
| 32 |
check_glance_outputs(gl) |
| 33 |
check_dims(gl, expected_cols = 1) |
| 34 |
}) |
| 35 |
|
| 36 |
test_that("augment.pam", { |
| 37 |
suppressWarnings( |
| 38 |
check_augment_function( |
| 39 |
aug = augment.pam, |
| 40 |
model = fit, |
| 41 |
data = x, |
| 42 |
newdata = x |
| 43 |
) |
| 44 |
) |
| 45 |
}) |