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

shape mapping Object ..missing.. not found #290

Closed
maksymiuks opened this issue Sep 3, 2021 · 3 comments
Closed

shape mapping Object ..missing.. not found #290

maksymiuks opened this issue Sep 3, 2021 · 3 comments

Comments

@maksymiuks
Copy link
Contributor

maksymiuks commented Sep 3, 2021

Hi!

First of all thank you for your amazing job under this package. I consider it great and love to see how it develops. I have one slight issue to consult though and I probably need a hand with that. It is slightly related to the issue #137. To cut long story short mapping works perfectly for color as you can see below but it fails for shape with an error Object ..missing.. not found (in English version may be slightly different, I translated it myself from my local). Do you have any idea what caused that? Use case of mine is that color mapping is not specified (desired is default one) while the shape is specified and second use case is when both are specified. Do you have any idea what might have causedd a problem?

Best
Szymon

data <- DALEX::apartments
data <- missForest::prodNA(data)
data$no.rooms <- as.factor(data$no.rooms)

library(ggplot2)
library(naniar)

ggplot(data = data, mapping = aes(.data$m2.price, .data$surface)) +
  geom_miss_point()

ggplot(data = data, mapping = aes(.data$m2.price, .data$surface, color = .data$district)) +
  geom_miss_point()

ggplot(data = data, mapping = aes(.data$m2.price, .data$surface, shape = .data$no.rooms)) +
  geom_miss_point()
#> Warning: Failed to apply `after_scale()` modifications to legend
#> Error in FUN(X[[i]], ...): Object '..missing..' not found

Created on 2021-09-03 by the reprex package (v2.0.1)

Additionally, I have one small question. Is it possible to make elements in ..missing. (when using geom with default settings) a factor with Missing and Not Missing levels? That way they will be always of the same color instead of swapping colors depending on if the data have or don't have missing values. It is really confusing.

@jonocarroll
Copy link

I haven't been able to get my head around how ggproto works enough to offer any suggestions for how to fix this, but a workaround might be to use stat_miss_point() which seems to work as a drop-in replacement, at least for the above example and others I tried (whether that's right or wrong is beyond my knowledge)

## using above construction
ggplot(data = data, mapping = aes(.data$m2.price, .data$surface, shape = .data$no.rooms)) +
  stat_miss_point()

stat_miss_point

## using construction in #137
mydat <- mtcars
mydat$mpg[1:10] = NA
ggplot(mydat, aes(x = mpg, y = disp, shape = factor(cyl))) +
  stat_miss_point(size = 4)

stat_miss_point_mtcars

Is there any reason one shouldn't do this?

Additionally, when the aesthetic variable is missing there's an additional layer of 'missingness' to deal with and I wonder if that should be handled by making 'missing' a new level of that scale?

@dicook
Copy link
Contributor

dicook commented Sep 21, 2021 via email

@njtierney
Copy link
Owner

Thank you @jonocarroll and @maksymiuks ! This has been closed in #293

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

No branches or pull requests

4 participants