Takes a previous interpolate_election_br() result and re-runs the
interpolation pipeline using the stored travel time matrix, skipping
the expensive routing step. Useful for switching to different candidates,
parties, what types, or election rounds without recomputing travel times.
Usage
reinterpolate(
result,
what = NULL,
candidates = NULL,
parties = NULL,
cargo = NULL,
turno = NULL,
reuse_weights = TRUE,
optim = optim_control(),
keep = NULL,
verbose = TRUE,
...
)Arguments
- result
An
interpElections_resultobject frominterpolate_election_br().- what
Character vector. Controls what information is interpolated. See
interpolate_election_br(). If NULL (default), reuses the original.- candidates
Character or numeric vector, or NULL. Filter candidates. See
interpolate_election_br().- parties
Character vector or NULL. Filter parties. See
interpolate_election_br().- cargo
Integer, character, or NULL. Override the electoral office. See
interpolate_election_br().- turno
Integer or NULL. Override the election round (1 or 2).
- reuse_weights
Logical. If TRUE (default), reuse the weight matrix from the original result to skip optimization. Automatically disabled when
turnoorcargochange (which alter calibration brackets).- optim
An
optim_control()object with optimization parameters. Only used whenreuse_weights = FALSE.- keep
Character vector or NULL. Extra objects to include in result.
weights,time_matrix,electoral_sf, andrep_pointsare always kept. Options:"pop_raster".- verbose
Logical. Print progress messages. Default: TRUE.
- ...
Additional arguments forwarded to
interpolate_election_br().
Value
An interpElections_result object (same structure as the
original, with updated interpolation).
Details
The previous result must contain a time_matrix (always kept by default).
When reuse_weights = TRUE (the default) and the stored weight matrix
is available, optimization is also skipped — making re-interpolation
near-instantaneous. Set reuse_weights = FALSE to force re-optimization
(e.g., when switching turno or cargo, which changes the calibration
brackets).
Examples
if (FALSE) { # \dontrun{
# First run
result <- interpolate_election_br(
3550308, 2022,
cargo = "presidente"
)
# Re-interpolate for parties (reuses weights, near-instant)
result2 <- reinterpolate(result, what = "parties")
# Re-interpolate for a different cargo (forces re-optimization)
result3 <- reinterpolate(result, cargo = "governador")
# Re-interpolate for turno 2 (forces re-optimization)
result4 <- reinterpolate(result, turno = 2)
# Force re-optimization even when calibration hasn't changed
result5 <- reinterpolate(result, what = "parties",
reuse_weights = FALSE)
} # }