if(interactive()){
plot(mtcars$mpg, mtcars$disp)
toxlsx(filename = file.path(tempdir(), "mtcars.xlsx"))
## use ggplot2
ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) + geom_point()
toxlsx(filename = file.path(tempdir(), "mtcars.xlsx"))
}
Run the code above in your browser using DataLab