tests/testthat/test-getSvdMostInfluential.R

library(testthat)
context("getSvdMostInfluential")

# simple matrix with known structure
m <- diag(1, 5)
colnames(m) <- paste0("v", 1:5)

res <- getSvdMostInfluential(m,
    quantile = 0.5, similarity_threshold = 0.5,
    plot_selection = FALSE
)

# result should be the special S3 class and contain expected elements
expect_s3_class(res, "Gmisc_svd_analysis")
expect_true(is.list(res))
expect_true("most_influential" %in% names(res))
expect_true("svd" %in% names(res))

# check that most_influential is integer vector
expect_type(res$most_influential, "integer")

# ensure missing values produce an error
m2 <- m
m2[1, 1] <- NA
expect_error(getSvdMostInfluential(m2, plot_selection = FALSE), "Missing values are not allowed")

Try the Gmisc package in your browser

Any scripts or data that you put into this service are public.

Gmisc documentation built on March 6, 2026, 9:09 a.m.