Puedes usar las siguiente función en lugar de labelFormat
labelFormat_decimal <- function (prefix = "", suffix = "", between = " – ", digits = 3,
big.mark = ",", transform = identity, decimal.mark = "."){
formatNum <- function(x) {
format(round(transform(x), digits), trim = TRUE, scientific = FALSE,
big.mark = big.mark, decimal.mark = decimal.mark,nsmall=digits)
}
function(type, ...) {
switch(type, numeric = (function(cuts) {
paste0(prefix, formatNum(cuts), suffix)
})(...), bin = (function(cuts) {
n <- length(cuts)
paste0(prefix, formatNum(cuts[-n]), between, formatNum(cuts[-1]),
suffix)
})(...), quantile = (function(cuts, p) {
n <- length(cuts)
p <- paste0(round(p * 100), "%")
cuts <- paste0(formatNum(cuts[-n]), between, formatNum(cuts[-1]))
paste0("<span title=\"", cuts, "\">", prefix, p[-n],
between, p[-1], suffix, "</span>")
})(...), factor = (function(cuts) {
paste0(prefix, as.character(transform(cuts)), suffix)
})(...))
}
}
Sólo pasa los parametros que necesitas
addLegend(pal = pal, values = ~ geomunicipios$Renta.media.por.hogar.2016,
position = "bottomright",
opacity = 1,
labFormat = labelFormat_decimal(suffix = "€", decimal.mark=",",
digits = 2, big.mark = "."),
title = "Renta Media Hogares (2016)")
Renta.media.por.hogar.2016
es numérica? ¿Que rango de valores maneja?