title: How to hide/toggle legends based on addLayerControl() in Leaflet for R
body: <p>I'm wondering how to hide/toggle legends based on <code>addLayerControl()</code> in Leaflet for R? When option layer a is toggled, then the data of option layer b is not shown by <code>addPolygons()</code> because I can use <code>group</code>. However, the <code>addLegend()</code> option doesn't have the <code>group</code> functionality so I'm not able to hide the legend of group layer b (blue) when I selected group layer a (red):</p>
  <p><a href="https://i.stack.imgur.com/TUbhz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TUbhz.png" alt="enter image description here" /></a></p>
  <p><a href="https://gis.stackexchange.com/questions/214773/how-to-hide-toggle-legends-with-layer-controls-in-leaflet-for-r">source</a></p>
  <p>Do you have any idea how to do this?</p>
  <p>Regards,</p>
  <p>Joris</p>