get_map_fill_data() prepares data to be used as fill in a map.
Usage
get_map_fill_data(
data,
col_fill = NULL,
col_code,
name_col_value = "n",
name_col_ref = col_code,
quiet = FALSE
)Arguments
- data
A
tibblewith the data to be used as fill.- col_fill
(optional) A
characterstring with the column name to be used as fill. IfNULL, the function will count the number of occurrences of each value incol_code(default:NULL).- col_code
A
characterstring with the column name to be used as reference.- name_col_value
(optional) A
characterstring with the name of the column to be used as value (default:"n").- name_col_ref
(optional) A
characterstring with the name of the column to be used as reference (default:col_code).- quiet
(optional) A
logicalflag to suppress messages (default:FALSE).
Value
A tibble.
See also
Other utility functions:
fix_postal_code(),
get_closest_geobr_year(),
remove_unique_outliers(),
unique_outliers()
Examples
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
data <- tibble(
state = c("SP", "RJ", "MG", "SP", "RJ", "MG"),
value = c(1, 2, 3, 4, 5, 6)
)
get_map_fill_data(data, col_fill = NULL, col_code = "state")
#> # A tibble: 3 × 2
#> state n
#> <chr> <int>
#> 1 MG 2
#> 2 RJ 2
#> 3 SP 2
get_map_fill_data(data, col_fill = "value", col_code = "state")
#> ! There are duplicated values in state. value will be aggregated using the mean.
#> # A tibble: 3 × 2
#> state n
#> <chr> <dbl>
#> 1 SP 2.5
#> 2 RJ 3.5
#> 3 MG 4.5
