tests/testthat/test-pca.R

test_that("multiplication works", {
  expect_equal(2 * 2, 4)
})

test_that("centre works", {
  expect_equal(centre(matrix(seq(1:9), nrow = 3)), centre(3 * matrix(seq(1:9), nrow = 3), T))
})

test_that("pca works",{
  data(iris)
  ref <- pca(iris[-5], F, 0.999)
  expect_equal(prcomp(iris[-5])$rotation, pca(iris[-5], F, 0.999)$pca_directions)
  # check methods don't produce errors
  print(ref)
  summary(ref)
  plot(ref)
  screeplot(ref)
})
eenticott/PCA documentation built on Jan. 10, 2021, 4:40 p.m.