Skip to contents

Check if a city can be in the scope (ok to be divided into several geographical contours)

Usage

valid_for_contours(
  tab_address,
  min_points_com,
  min_address_bv,
  var_bv1,
  var_nbaddress
)

Arguments

tab_address

addresses of a single city

min_points_com

minimal number of points by city (global parameter)

min_address_bv

minimal number of address by vote office (global parameter)

var_bv1

name for bv code variable in address table

var_nbaddress

name for number of addresses for each point in address table

Value

  • TRUE if the city is in the scope,

  • otherwise FALSE or a list of problematic BVs

Details

The function uses the addresses of the city targeted

Examples

tab_address <- mapvotr::addresses_sample
min_points_com <- 50
min_address_bv <- 15
var_bv1 <- "id_brut_bv_reu"
var_nbaddress <- "nb_adresses"
mapvotr:::valid_for_contours(tab_address, min_points_com, min_address_bv, var_bv1, var_nbaddress)
#> [1] "Launch valid_for_contours"
#> Log is not open.
#> [1] "No problem"
#> Log is not open.
#> [1] TRUE

# With some problematic BVs
lines_pb <- tab_address[tab_address$id_brut_bv_reu == "29039_1", ][1:5, ]
tab_address_pb <- tab_address[tab_address$id_brut_bv_reu != "29039_1", ] %>% rbind(lines_pb)
mapvotr:::valid_for_contours(tab_address_pb, min_points_com, min_address_bv, var_bv1, var_nbaddress)
#> [1] "Launch valid_for_contours"
#> Log is not open.
#> [1] "Not enough addresses by BV (threshold = 15)"
#> Log is not open.
#> # A tibble: 1 × 2
#>   id_brut_bv_reu nb_address
#>   <chr>               <int>
#> 1 29039_1                11
#> Log is not open.
#> [1] "29039_1"