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

Error with factor in x axis and geom_line() #160

Closed
caayala opened this issue Oct 27, 2020 · 1 comment · Fixed by #161
Closed

Error with factor in x axis and geom_line() #160

caayala opened this issue Oct 27, 2020 · 1 comment · Fixed by #161

Comments

@caayala
Copy link

caayala commented Oct 27, 2020

library(ggplot2)
library(gghighlight)

d <- data.frame(
  idx = c(1, 1, 1, 2, 2, 2, 3, 3, 3),
  value = c(1, 2, 3, 10, 11, 12, 9, 10, 11),
  category = rep(c("a", "b", "c"), 3),
  stringsAsFactors = FALSE
)

# var x as continuous works
ggplot(d, aes(x = idx, y = value, colour = category)) +
  geom_line() + 
  gghighlight(category == 'b', use_group_by = FALSE)
#> label_key: category

# var x as character works as expected
d$idx <- as.character(d$idx)

ggplot(d, aes(x = idx, y = value, colour = category,
              group = category)) +
  geom_line() + 
  gghighlight(category == 'b', use_group_by = FALSE)
#> label_key: category

# var x as factor dosn't works as expected
d$idx <- as.factor(d$idx)

ggplot(d, aes(x = idx, y = value, colour = category,
              group = category)) +
  geom_line() + 
  gghighlight(category == 'b', use_group_by = FALSE)
#> label_key: category
#> Error: Problem with `filter()` input `..1`.
#> x 'max' not meaningful for factors
#> ℹ Input `..1` is `idx == max(idx)`.
#> ℹ The error occurred in group 1: category = "b".

cc @vicky-rojas.

Created on 2020-10-27 by the reprex package (v0.3.0)

@yutannihilation
Copy link
Owner

Thanks, confirmed. I'll fix this soon...

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

Successfully merging a pull request may close this issue.

2 participants