breaks: Selects the breaks

Description Usage Arguments Details Value Examples

View source: R/breaks.R

Description

This function selects the class intervals for a numeric column in a data frame.

Usage

1
2
breaks(df, col_name, n = 6, style = "quantile", pal = NULL,
  fixedBreaks = NULL, distribution = FALSE)

Arguments

df

a data frame containing at least one numeric column

col_name

name of the column containing the value on which the class intervals should be calculate

n

a numeric indicating the number of intervals to represent the data (by default, n = 6)

style

a character value issued from the classint package, and used to select a method for the different way of calculating the intervals (by default style = "quantile")

pal

the color for the distribution legend, by default NULL

fixedBreaks

By default NULL but if a vector of value is inputted, it will be used to specifen the breaks, need to used with the parameter style = "fixed"

distribution

if TRUE, print on the map, the distribution of the values by intervals

Details

For more information on the parameter style, please, look at the package classint.

Value

The data frame inputed with attributes breaks corresponding to the breaks value, returned invisibly.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Example with data preparation
library(gdpm)
library(dplyr)
dengue <- getid(dengue, from = 1990, to = 1991)
dengue_prep <- filter(dengue, year == 1990, month == "September")

a <- breaks(dengue_prep, "incidence_dengue")
str(a)
# to extract the breaks value
attr(a, "breaks")

# to print the distribution
breaks(dengue_prep, "incidence_dengue", pal = heat.colors(6),
       distribution = TRUE)

# to change the style or number of breaks
breaks(dengue_prep, "incidence_dengue", n = 8, style = "fisher")
breaks(dengue_prep, "incidence_dengue", n = 8, style = "fisher",
       pal = heat.colors(8), distribution = TRUE)

# to use the "fixed" style
breaks(dengue_prep, "incidence_dengue", n = 6, style = "fixed",
       fixedBreaks = c(0, 50, 100, 500, 1000, 1500, 2000))
breaks(dengue_prep, "incidence_dengue", n = 6, style = "fixed",
       pal = heat.colors(6), distribution = TRUE,
       fixedBreaks = c(0, 50, 100, 500, 1000, 1500, 2000))

choisy/poseid documentation built on Aug. 22, 2019, 4:45 a.m.