walkerke / mapgl

R interface to Mapbox GL JS v3 and Maplibre GL JS
https://walker-data.com/mapgl
Other
91 stars 5 forks source link

Handle categorical variables in `step_expr()` #14

Closed joshcullen closed 4 months ago

joshcullen commented 4 months ago

I've been enjoying learning to use {mapgl} after having used {leaflet} almost entirely for my interactive mapping needs. It would be great if the step_expr function could be modified to accommodate categorical data (i.e., not converting numerical data into categories) when using add_fill_layer since I have some use cases where this would be very helpful.

Not sure how it works on the backend, but may alternatively be easier to create a new function to handle categorical variables instead.

walkerke commented 4 months ago

The match_expr() function is what you need! This is what you'll use for categorical mapping.

https://walker-data.com/mapgl/reference/match_expr.html

joshcullen commented 4 months ago

Thanks so much! I must've missed that.