-
Notifications
You must be signed in to change notification settings - Fork 23
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
Can we use gghighlight()
for autoplot()
?
#66
Comments
Thanks, confirmed. The reason of the error is that the data of the second layer doesn't contain library(glmnetUtils)
library(ggfortify)
#> Loading required package: ggplot2
model <- glmnet(medv ~ ., data = MASS::Boston)
g <- autoplot(model, xvar = "lambda")
lapply(g$layers, function(l) {
if (is.data.frame(l$data)) {
head(l$data)
} else {
l$data
}
})
#> [[1]]
#> list()
#> attr(,"class")
#> [1] "waiver"
#>
#> [[2]]
#> crim zn indus chas nox rm age dis rad tax ptratio
#> s21 0 0 0 0.128706 0 3.8961005 0 0 0 0 -0.6305235
#> s17 0 0 0 0.000000 0 3.5480395 0 0 0 0 -0.5076149
#> s14 0 0 0 0.000000 0 3.2365996 0 0 0 0 -0.3713991
#> s10 0 0 0 0.000000 0 2.6603223 0 0 0 0 -0.1192839
#> s7 0 0 0 0.000000 0 1.9756431 0 0 0 0 0.0000000
#> s3 0 0 0 0.000000 0 0.5694424 0 0 0 0 0.0000000
#> black lstat Df Lambda dev.ratio index label_y
#> s21 0.002301817 -0.4975636 5 0.9607149 0.6653606 -0.04007759 4.272373
#> s17 0.000000000 -0.4828300 3 1.3938328 0.6418216 0.33205737 4.272373
#> s14 0.000000000 -0.4541851 3 1.8425650 0.6143107 0.61115860 4.272373
#> s10 0.000000000 -0.4011381 3 2.6732463 0.5432586 0.98329356 4.272373
#> s7 0.000000000 -0.3353772 2 3.5338742 0.4552422 1.26239478 4.272373
#> s3 0.000000000 -0.1969814 2 5.1270464 0.2526918 1.63452975 4.272373 Created on 2018-09-21 by the reprex package (v0.2.1) Unfortunately, currently there's no way to apply So, the workaround would be a bit tricky. Sorry for the inconvenience, I will consider implementing a new feature for this. library(glmnetUtils)
library(ggfortify)
#> Loading required package: ggplot2
model <- glmnet(medv ~ ., data = MASS::Boston)
g <- autoplot(model, xvar = "lambda")
l <- g$layers[[2]]
g$layers[[2]] <- NULL
library(gghighlight)
g <- g +
gghighlight(variable == "crim", use_group_by = FALSE)
#> label_key: variable
g$layers[[3]] <- l
g Created on 2018-09-21 by the reprex package (v0.2.1) |
Thank you! |
FYI: This is now possible with the dev version. library(gghighlight)
#> Loading required package: ggplot2
library(glmnetUtils)
library(ggfortify)
model <- glmnet(medv ~ ., data = MASS::Boston)
autoplot(model, xvar = "lambda") +
gghighlight(variable == "crim", use_group_by = FALSE)
#> Warning: Could not calculate the predicate for layer 2; ignored
#> label_key: variable Created on 2018-12-28 by the reprex package (v0.2.1) |
Hi, thank you for the greatest package.
Now, I'm trying to use
gghighlight()
for a result ofautoplot()
, but it occurs an error.For instance:
What would you suggest I do?
The text was updated successfully, but these errors were encountered: