The Leaflet JS mapping library has lots of plugins available. The Leaflet package for R provides direct support for some, but far from all, of these plugins, by providing R functions for invoking the plugins.
If you as an R user find yourself wanting to use a Leaflet plugin that isn't directly supported in the R package, you can use the technique shown here to load the plugin yourself and invoke it using JS code.


One more thing for others looking for help with this. You can't use
forEachin your insideOnRender. I think this has to do with the fact thatthishas special meaning inforEach- I'm not a javascript programmer so that's about the extent of my knowledge - and sincethisis the map they don't play nice together. Convert yourforEachto afor-loop.