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

Use names of named vectors for plotting #229

Open
mattansb opened this issue Jul 12, 2021 · 1 comment
Open

Use names of named vectors for plotting #229

mattansb opened this issue Jul 12, 2021 · 1 comment
Labels
enhancement 💥 Implemented features can be improved or revised

Comments

@mattansb
Copy link
Contributor

library(ggeffects)

fit <- lm(mpg ~ hp * drat, data = mtcars)

This function returns a named vector

ZZZ <- function(x) {
  c(A = median(x) - 2,
    B = median(x) + 2)
}

ZZZ(rnorm(4))
#>         A         B 
#> -1.377492  2.622508

Would be nice if these names were used in the plot’s legend… (:

plot(ggpredict(fit, terms = c("hp", "drat [ZZZ]")))
#> Loading required namespace: ggplot2

Same for a vector

CCC <- c(O = -9, zap = 20) 
plot(ggpredict(fit, terms = c("hp", "drat [CCC]")))

Created on 2021-07-12 by the reprex package (v2.0.0)

@strengejacke strengejacke added the enhancement 💥 Implemented features can be improved or revised label Jul 19, 2021
strengejacke added a commit that referenced this issue Nov 24, 2021
@strengejacke
Copy link
Owner

This one is harder than expected...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 💥 Implemented features can be improved or revised
Projects
None yet
Development

No branches or pull requests

2 participants