tests/testthat/test-multi_polygon.R

test_that("multi-modal densities work", {
  set.seed(10)
  x = c(rnorm(50), rnorm(50, mean = 3))
  y = c(rnorm(50), rnorm(50, mean = 3))
  output = density_polygons(x, y, probs = c(0.1), as_sf = T, as_list = F)
  expect_s3_class(
    output$geometry,
    "sfc_MULTIPOLYGON"
  )
})

test_that("multi-modal densities work", {
  set.seed(10)
  x = rnorm(100)
  y = rnorm(100)
  probs = ppoints(10)
  output = density_polygons(x, y, probs = probs, as_sf = T, as_list = F)
  expect_equal(
    length(probs),
    nrow(output)
  )

})

Try the densityarea package in your browser

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

densityarea documentation built on Aug. 8, 2025, 6:23 p.m.