Learn R Programming

eurostat (version 2.2.1)

cut_to_classes: Cuts the Values Column into Classes and Polishes the Labels

Description

Categorises a numeric vector into automatic or manually defined categories. and polishes the labels ready for used in mapping with merge_with_geodata function and ggplot2.

Usage

cut_to_classes(x, n = 5, style = "jenks", manual = FALSE, manual_breaks = NULL, decimals = 0, nodata_label = "No data")

Arguments

x
A numeric vector, eg. values variable in data returned by get_eurostat
n
A numeric. number of classes/categories
style
Chosen style: one of "fixed", "sd", "equal", "pretty", "quantile", "kmeans", "hclust", "bclust", "fisher", or "jenks"
manual
Logical. If manual breaks are being used
manual_breaks
Numeric vector with manual threshold values
decimals
Number of decimals to include with labels
nodata_label
String. Text label for NA category.

Value

a factor.

Examples

Run this code
 ## Not run: 
#    lp <- get_eurostat("nama_aux_lp")
#    lp$class <- cut_to_classes(lp$values, n=5, style="jenks",decimals=1)
#  ## End(Not run)

Run the code above in your browser using DataLab