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