tests/testthat/test_layout_functions.R

context("treemap_squarified()")

G20_onezero <- G20_allzero <- G20
G20_onezero[1, "gdp_mil_usd"] <- 0
G20_allzero$gdp_mil_usd <- rep(0, nrow(G20_allzero))

test_that("treemap_squarified() correctly handles tiles with areas of 0", {
  expect_silent(treemap_squarified(G20_onezero, area = "gdp_mil_usd"))
  expect_error(treemap_squarified(G20_allzero, area = "gdp_mil_usd"), "area > 0")
})

context("treemap_fixed()")

test_that("treemap_fixed() correctly handles tiles with areas of 0", {
  expect_silent(treemap_fixed(G20_onezero, area = "gdp_mil_usd"))
  expect_error(treemap_fixed(G20_allzero, area = "gdp_mil_usd"), "area > 0")
})

Try the treemapify package in your browser

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

treemapify documentation built on Sept. 30, 2023, 9:07 a.m.