Is there a convenient way to extract the data from a gam plot, without actually plotting the gam object?
Here's a dummy example. plot.data
has the data I want in it, but I don't want the plot window to be affected.
library(mgcv)
x=1:10000/1000
y = sin(x)+rnorm(10000,sd=2)
m = gam(y~s(x))
plot.data<-plot(m,plot=F)
It doesn't look like plot.gam
has the option for not plotting. But you could try
plot.data <- {
dev.new()
res <- plot(m)
dev.off()
res
}
or possibly
plot.data <- {
pdf(NULL)
res <- plot(m)
invisible(dev.off())
res
}