I am trying to make a leaflet map in R with custom markers for a categorical variable. I used the example at https://rstudio.github.io/leaflet/markers.html as a starting point, but as it uses a numerical variable I adapted as follows:
 logos <- iconList(
 LA = makeIcon("~/mydata/la_logo.png","la_logo-15@2x.png", 15, 15),
 CO = makeIcon("~/mydata/co_logo.jpg","co_logo-15@2x.png", 15,15),
 CF = makeIcon("~/mydata/cf_logo.png","cf_logo-15@2x.png", 15,15),
 NN = makeIcon("~/mydata/nn_logo.png","nn_logo-15@2x.png", 15,15)
 )
leaflet(data) %>%
 addTiles() %>%
 addProviderTiles("CartoDB.Positron") %>%
 addMarkers(icon = ~logos[var]
 )
In data, the variable var has the values "LA", "CO", "CF" and "NN" and lat and lon (latitude and longitude respectively).
I have verified that the images are in the url declared. Any ideas? thanks

