Skip to content

Combining data fields in scale_color_ #109

@edmundseto

Description

@edmundseto

Hi,

Thanks for developing this package. It's amazing! I'm new to this, so forgive me for probably a simple question. I've been looking for more examples, and haven't come across what I need.

I'm trying to add two numeric data fields from my vector tile, and use the results in the color scaling function for the map. The code below works with just one data field (DM_W), but not when I try to combine two fields (e.g., DM_W + DM_A) as shown. Any suggestions would be appreciated.

rdeck() |>
  add_mvt_layer(
    data = tile_json("https://{my server's IP}/services/simple_polygons"),
    get_fill_color = scale_color_linear(
      col = DM_W + DM_A
    ),
    pickable = TRUE,
    tooltip = c(GEOID10, DM_W, DM_A),
  ) 

I get an error...

Error in `add_mvt_layer()`:
! Failed to create layer
Caused by error in `rlang::ensym()`:
! Can't convert to a symbol.
Run `rlang::last_trace()` to see where the error occurred.

From the ensym() error, I think it's expecting just a column name rather than an expression, but my R skills aren't good enough to come up with a work around.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions