
Get the closest year available in the geobr package
Source: R/closest_geobr_year.R
closest_geobr_year.Rdclosest_geobr_year() returns the closest year available in the
geobr package for a specified type of data.
Arguments
- year
An
integerishvector with the year to find the closest available year in thegeobrpackage.- type
(optional) A
characterstring indicating the type of data to find the closest year for. It can be one of the following:"municipality","municipal_seat","state", or"country"(default:"country").- verbose
(optional) A
logicalflag indicating whether to print a warning message if the specified year is not available in thegeobrpackage. Only applicable ifyearis a single value (default:TRUE).
Value
A numeric vector with the closest year available
in the geobr package for the specified type of data.
See also
Other utility functions:
fix_postal_code(),
map_fill_data(),
remove_unique_outliers(),
test_geobr_connection(),
unique_outliers()
Examples
closest_geobr_year(2025, type = "municipality")
#> ! The closest map year to 2025 is 2024. Using year 2024 instead.
#> [1] 2024
#> [1] 2022 # Expected
closest_geobr_year(2025, type = "municipal_seat")
#> ! The closest map year to 2025 is 2010. Using year 2010 instead.
#> [1] 2010
#> [1] 2010 # Expected
closest_geobr_year(2025, type = "state")
#> ! The closest map year to 2025 is 2020. Using year 2020 instead.
#> [1] 2020
#> [1] 2020 # Expected
closest_geobr_year(2025, type = "country")
#> ! The closest map year to 2025 is 2020. Using year 2020 instead.
#> [1] 2020
#> [1] 2020 # Expected
closest_geobr_year(c(2025, 1999, NA, 1800), type = "country")
#> [1] 2020 2000 NA 1872
#> [1] 2020 2000 NA 1872 # Expected