riatelab / cartography

Thematic Cartography for R
http://riatelab.github.io/cartography/docs/
397 stars 46 forks source link

Update getBreaks.R #88

Closed pompolompo closed 8 months ago

pompolompo commented 8 months ago

Takes care of zero values in the "geom" method

rCarto commented 8 months ago

Thank you for the PR.

cartography is superseded by mapsf. The "geom" method is also available with mapsf::mf_get_breaks(..., breaks = "geom"). In mapsf an error occur if some values are not greater than 0 (your modification only works for values = 0) .

See:

library(mapsf)
m <- mf_get_mtq()
m$POP[1:3] <- 0:-2
mf_get_breaks(m$POP, 5, "geom")
#> Error: All values must be strictly greater than 0 when using the 'geom' method.

Created on 2024-01-15 with reprex v2.1.0

I would accept a PR that mimics what mapsf is doing.

See: https://github.com/riatelab/mapsf/blob/a5377c12705218cd9516f277ea54d2d2870902fe/R/mf_get_breaks.R#L68