tests/testthat/test-vizAnnualClimate.R

context("vizAnnualClimate")

## tests
library(aqp, quietly = TRUE)
suppressWarnings(library(cluster, quietly = TRUE))
suppressWarnings(library(dendextend, quietly = TRUE))
suppressWarnings(library(latticeExtra, quietly = TRUE))

test_that("vizAnnualClimate works as expected", {
  
  # use local data
  data("OSDexamples")
  a <- OSDexamples$climate.annual
  
  # with / without highlight
  res <- vizAnnualClimate(a)
  res <- vizAnnualClimate(a, s = 'ZOOK')
  
  # print(res$fig)
  
  # list of lattice + clustering
  expect_true(inherits(res, 'list'))
  expect_true(inherits(res$fig, 'trellis'))
  expect_true(inherits(res$clust, 'diana'))
  
  # try a singleton
  res <- vizAnnualClimate(a[1:8, ])
  expect_true(inherits(res, 'list'))
  expect_true(inherits(res$fig, 'trellis'))
  # no clustering possible, result is NULL
  expect_false(inherits(res$clust, 'diana'))
  
})

Try the sharpshootR package in your browser

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

sharpshootR documentation built on Oct. 23, 2024, 1:06 a.m.