Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

col.regions doesn't work well when subsetting #433

Open
AnthonyDEBUR opened this issue Jul 5, 2022 · 0 comments
Open

col.regions doesn't work well when subsetting #433

AnthonyDEBUR opened this issue Jul 5, 2022 · 0 comments

Comments

@AnthonyDEBUR
Copy link

Hello,

It seems there is a problem with col.regions when a factor has got multiple levels and dataset only has one used level.
Bellow is a reproducing example.

First map view give the right output with points appearing orange and blue.
image

Second map give the wrong output with points red (first color of legend) instead of blue
image

library(mapview)

# selecting only not NA seasonnal beers and transforming as factor
breweries<-breweries[!is.na(breweries$number.seasonal.beers),]

breweries$number.seasonal.beers <-
  as.factor(breweries$number.seasonal.beers)
summary(breweries$number.seasonal.beers)

# personnal color scale with 2 non missing levels --> work with orange and blue points

breweries1_4<-breweries[breweries$number.seasonal.beers%in%c("1","4"),]

mapview(
  breweries1_4,
  zcol = "number.seasonal.beers",
  col.regions = c("red", "orange", "yellow", "green", "blue", "white")
)

# same map seleting only one levels. Should be blue points and not red
breweries4<-breweries[breweries$number.seasonal.beers=="4",]

mapview(
  breweries4,
  zcol = "number.seasonal.beers",
  col.regions = c("red", "orange", "yellow", "green", "blue", "white")
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant