How to upload a map on Leaftlet? Error in addPolygons and object cannot be found

I am making a map through leaflet from a tutorial.I followed it and I used the code below to make the map:

m<- leaflet() %>%
   setView(-96,37,4) %>%
   addProviderTiles(providers$Stamen.Toner)%>%
   addPolygons(data =districts,
               weight = 1,
               smoothFactor = 0.5,
               color = "white",
               fillOpacity = 0.8,
               fillcolor= pal(fb$per.content))
m

However, i keep getting this error:

Error in addPolygons(., data = districts, weight = 1, smoothFactor = 0.5,  : 
  unused argument (fillcolor = pal(fb$per.content))
> m
Error: object 'm' not found

I am not sure why I got an error, I appreciate input here.

An unused argument error most often means that one made a typo while spelling the argument.
In your case you spelled fillcolor where the function expects fillColor.

In general it is good practice to make a small (as small a possible) example that contains all the elements that play a role in your problem. See FAQ: What's a reproducible example (`reprex`) and how do I do one? .
In this case I expected the typo (from my own experience) and supposed you were using the leaflet package, so the answer of your question was easily found. But otherwise I would not have known where to find districts, pal and fb.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.