I'm wondering how to hide/toggle legends based on `addLayerControl()` in Leaflet for R? When option layer a is toggled, then the data of option layer b is not shown by `addPolygons()` because I can use `group`. However, the `addLegend()` option doesn't have the `group` functionality so I'm not able to hide the legend of group layer b (blue) when I selected group layer a (red):

[![enter image description here](https://i.stack.imgur.com/TUbhz.png)](https://i.stack.imgur.com/TUbhz.png)

[source](https://gis.stackexchange.com/questions/214773/how-to-hide-toggle-legends-with-layer-controls-in-leaflet-for-r)

Do you have any idea how to do this?

Regards,

Joris