test_that("aggregation sums additive accounts before calculating ratios", { x <- agri_pam_example() total <- pam_aggregate(x) expect_equal(nrow(pam_values(total)), 1) expect_equal( pam_values(total)$private_revenue, sum(pam_values(x)$private_revenue) ) grouped <- pam_aggregate(x, c("Cereal", "Cereal", "Other", "Other")) expect_equal(pam_values(grouped)$id, c("Cereal", "Other")) expect_equal( pam_values(grouped)$private_profit[1], sum(pam_values(x)$private_profit[1:2]) ) }) test_that("matrix selection and summaries support multiple systems", { x <- agri_pam_example() matrices <- pam_matrix(x, c("Paddy", "Wheat")) expect_type(matrices, "list") expect_named(matrices, c("Paddy", "Wheat")) s <- summary(x) expect_s3_class(s, "summary_agri_pam") expect_equal(nrow(s$overview), 4) expect_true(all(s$overview$comparative_advantage)) expect_output(print(x), "") expect_output(print(s), "Policy Analysis Matrix summary") })