
Get the closest year available in geobr
package
Source: R/get_closest_geobr_year.R
get_closest_geobr_year.Rd
get_closest_geobr_year()
returns the closest year available in the
geobr
package for a specified type of data.
Arguments
- year
An
integerish
vector with the year to find the closest available year in thegeobr
package.- type
(optional) A string 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
logical
flag indicating whether to print a warning message if the specified year is not available in thegeobr
package. Only applicable ifyear
is 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()
,
get_map_fill_data()
Examples
get_closest_geobr_year(2025, type = "municipality")
#> ! The closest map year to 2025 is 2022. Using year 2022 instead.
#> [1] 2022
#> [1] 2022 # Expected
get_closest_geobr_year(2025, type = "state")
#> ! The closest map year to 2025 is 2020. Using year 2020 instead.
#> [1] 2020
#> [1] 2020 # Expected
get_closest_geobr_year(2025, type = "country")
#> ! The closest map year to 2025 is 2020. Using year 2020 instead.
#> [1] 2020
#> [1] 2020 # Expected
get_closest_geobr_year(c(2025, 1999, NA, 1800), type = "country")
#> [1] 2020 2000 NA 1872
#> [1] 2020 2000 NA 1872 # Expected