I have a function like this:
fun <- function(dataset){
require(ggplot2)
g <- ggplot(dataset, aes(x = x, y = y)) + geom_smooth(method = "lm") + geom_point()
l<-lm(y~x)
return (list(l, g))
}
and I want to return both plot and the values, but it doesn't return the plot and I face this error:
Error in .Call.graphics(C_palette2, .Call(C_palette2, NULL)) :
invalid graphics state
What can I do?
ginstead ofp), but this shouldn't be the main issue, I figure.