tests/testthat/test-set_small_parties_to_other.R

context("test-set_small_parties_to_other")

test_that("subbing parties with 'Other' works", {
  dataset_name <- "yle_2011"
  data <- get_dataset(dataset_name,filter_precinct=c("01 Helsingin vaalipiiri"))
  party_col <- get_functional_column_name(data,alternative_spellings = c("puolue","Puolue","party"))
  parties <- set_small_parties_to_other(data, party_col)  
  expect_equal(sum(parties=="Other"), 26)
  expect_equal(length(parties), nrow(data))
})
tjpajala/vaalikone documentation built on May 26, 2019, 9:34 a.m.