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

Possible bug in ggscatterstats #96

Closed
ibecav opened this issue Dec 5, 2018 · 2 comments
Closed

Possible bug in ggscatterstats #96

ibecav opened this issue Dec 5, 2018 · 2 comments

Comments

@ibecav
Copy link
Contributor

ibecav commented Dec 5, 2018

label.expression works for single conditions but seems to fail silently for a joint condition. See reprex (sorry for some reason on my machine it's only rendering the final plot but I assure you the first two are working.

library(ggstatsplot)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
# Remove non unique movies for clarity
# Test "length < 60" it works
ggscatterstats(
  data = distinct(movies_long, title, year, .keep_all = TRUE),
  x = length,
  y = budget, 
  label.expression = "length < 60", 
  label.var = "title"
)
#> Warning: This plot can't be further modified with `ggplot2` functions.
#> In case you want a `ggplot` object, set `marginal = FALSE`.
#> 
# Remove non unique movies for clarity
# Test "budget > 150" it works
ggscatterstats(
  data = distinct(movies_long, title, year, .keep_all = TRUE),
  x = length,
  y = budget, 
  label.expression = "budget > 150", 
  label.var = "title"
)
#> Warning: This plot can't be further modified with `ggplot2` functions.
#> In case you want a `ggplot` object, set `marginal = FALSE`.
#> 
# Remove non unique movies for clarity
# Try both and it silently drops the labels
ggscatterstats(
  data = distinct(movies_long, title, year, .keep_all = TRUE),
  x = length,
  y = budget, 
  label.expression = "budget > 150 & length < 60", 
  label.var = "title"
)
#> Warning: This plot can't be further modified with `ggplot2` functions.
#> In case you want a `ggplot` object, set `marginal = FALSE`.
#> 

Created on 2018-12-05 by the reprex package (v0.2.1)

@IndrajeetPatil
Copy link
Owner

Correct me if I am wrong, but it's not failing. There are just no labels to show because there are no movies with budget > 150 and length < 60.

library(ggstatsplot)
library(dplyr)

distinct(movies_long, title, year, .keep_all = TRUE) %>%
  filter(budget > 150 & length < 60)
#> # A tibble: 0 x 8
#> # ... with 8 variables: title <fct>, year <int>, length <int>,
#> #   budget <dbl>, rating <dbl>, votes <int>, mpaa <fct>, genre <fct>

If you choose a different expression, it works-

library(ggstatsplot)
library(dplyr)

ggscatterstats(
  data = distinct(movies_long, title, year, .keep_all = TRUE),
  x = length,
  y = budget, 
  label.expression = "budget > 100 & length > 150", 
  label.var = "title"
)
#> Warning: This plot can't be further modified with `ggplot2` functions.
#> In case you want a `ggplot` object, set `marginal = FALSE`.
#> 

@ibecav
Copy link
Contributor Author

ibecav commented Dec 5, 2018 via email

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

2 participants