walkerke / mapgl

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

Handle categorical variables in `step_expr()` #14

Closed joshcullen closed 2 months ago

joshcullen commented 2 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 2 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 2 months ago

Thanks so much! I must've missed that.