[ggplot::ggsave] Error in UseMethod("grid.draw")
Bonjour,
J'ai créé un graphe bwplot issus du package lattice et je souhaiterai sauvegarder ce plot, j'utilise la fonction ggsave issue du package ggplot2 mais il me renvoie cette erreur.
Code:
1 2
| Error in UseMethod("grid.draw") :
no applicable method for 'grid.draw' applied to an object of class "trellis" |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| library(caret)
library(ggplot2)
train <- data.frame("a" = rnorm(100), "b" = rnorm(100))
act <- rnorm(100)
m1 <- train(train, act, method="svmLinear")
m2 <- train(train, act, method="svmRadial")
l <- list("svmLinear" = m1, "svmRadial" = m2)
scales <- list(x=list(relation="free"), y=list(relation="free"))
bwp <- bwplot(resamples(l), scales=scales, metric=c("Rsquared", "RMSE"))
ggsave(plot = bwp, filename = "bwplot.pdf", dpi = 400, device = "pdf",
width = 300,height = 300,
units = c("mm"),limitsize = FALSE) |