dreamRs / esquisse

RStudio add-in to make plots interactively with ggplot2
https://dreamrs.github.io/esquisse
Other
1.78k stars 232 forks source link

error using sf data in combination with size #29

Closed itcarroll closed 6 years ago

itcarroll commented 6 years ago

Worked awesome with the meuse dataset's landuse variable set to "Color", but borked on setting the same to "Size".

data('meuse', package = "sp")
df <- sf::st_as_sf(meuse, coords = c('x', 'y'), crs = 28992)
esquisser(df)
screen shot 2018-10-09 at 10 48 53 pm

esquisser version: 9340e358af76f6f44307d4501ce2659fd34eec6f

pvictor commented 6 years ago

Hi! Probably in issue in ggplot2, size dont seems to handle missing values, if you remove it, it works :

library(ggplot2)
data('meuse', package = "sp")
df <- sf::st_as_sf(meuse, coords = c('x', 'y'), crs = 28992)
# one missing value : error
ggplot(data = df) +
  aes(size = landuse) +
  geom_sf() +
  theme_minimal()

# remove missing value : works
df <- df[!is.na(df$landuse), ]
ggplot(data = df) +
  aes(size = landuse) +
  geom_sf() +
  theme_minimal()

I took the opportunity to add a better management of warnings and errors, now it looks like this:

image

itcarroll commented 6 years ago

Nice! Maybe I'll poke the tidyverse ...