tests/testthat/test-aggregate.R

# Test aggregation

test_that("Aggregation works as expected", {

  expect_class({
    spm_aggregate(biomass_dataset_smoothed, variable = "weight_per_km2",
                  fun = mean, type = "smoothed", group_by = "time")
  }, "sspm_dataset")

  expect_class({
    spm_aggregate(biomass_dataset_smoothed, variable = "weight_per_km2",
                  fun = mean, type = "smoothed", group_by = "space",
                  level = "boundary")
  }, "sspm_dataset")

  # expect_class({
  #   spm_aggregate(biomass_dataset_smoothed, variable = "weight_per_km2",
  #                 fun = mean, type = "smoothed", group_by = "space",
  #                 apply_to_df = TRUE)
  # }, "sspm_dataset")

  expect_class({
    spm_aggregate(biomass_dataset_smoothed, variable = "weight_per_km2",
                  fun = mean, type = "smoothed", group_by = "space")
  }, "sspm_dataset")

  # expect_class({
  #   spm_aggregate(biomass_dataset_smoothed, variable = "weight_per_km2",
  #                 fun = mean, type = "smoothed", group_by = "space",
  #                 fill = NA)
  # }, "sspm_dataset")

  # expect_class({
  #   spm_aggregate(biomass_dataset_smoothed, variable = "weight_per_km2",
  #                 fun = mean, type = "smoothed", group_by = "space",
  #                 fill = 0)
  # }, "sspm_dataset")

})

Try the sspm package in your browser

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

sspm documentation built on April 4, 2025, 1:43 a.m.