Export and import graphics and tables to MicroSoft office ## Description eoffice provide wrap functions to export and import graphics and data.frames in R to MicroSoft office (docx, pptx format) And eoffice also provide write out figures with lots of different formats, such as pdf, eps, emf, tiff, svg, wmf, png and jpeg. eoffice also support write out or display ggplot2 type figure with plotly. Since people may work on the platform without GUI support, eoffice also provide function to easily write out figures to all above formats, pptx and docx. ## Installation


Software Usage

## make a figure with you custom function
plot(mtcars$mpg, mtcars$disp)
topptx(filename = "mtcars.pptx")
## You can also use ggplot 
ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) + geom_point()
topptx(filename = "mtcars.pptx")
## or todocx(filename = "mtcars.docx")
p <- ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) + geom_point()
topptx(p, filename = "mtcars.pptx", width = 6, height = 4)
## use above method if you want use topptx with ggplot function in a loop
## write out table to office
totable(head(mtcars), filename = "mtcars.docx")
totable(head(mtcars), filename = "mtcars.pptx")
## append was supported if you want add figures or tables.
## Now support direct output of common objects produced by R statistical functions
tt <- t.test(wt ~ am, mtcars)
totable(tt, filename = "mtcars_test.pptx")
totable(t.test(wt ~ am, mtcars), filename = "mtcars_test.pptx")
## inpptx and indocx provide function read the tables in pptx or docx
tabs <- inpptx(filename = "mtcars.pptx", header = TRUE)
## output different figure formats
tofigure(ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) + geom_point(),filename = "mtcars.pdf")
tofigure(ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) + geom_point(),filename = "mtcars.eps")
## display figure with plotly
tohtml(p, save = FALSE)
## if you use basic plot function or other plot function you need first use convertplot to convert 
## it to ggplot object when you are working on the platform without GUI
p <- convertplot(plot(1:10))
tofigure(p, filename = "test.pdf")
topptx(p, filename = "test.pptx")
## if you use ggplot like function you don't need to transform the format


The eoffice just a package for funs. eoffice depends on officer and rvg package which include lots of fantastic functions. Here, eoffice provides simplified functions which could be save some time to learn the complete functions from above packages. And there are some packages provide these functions. Comparing with these packages, eoffice include own features which I think really helpful to me. Besides, eoffice also provide functions to read tables from pptx and docx. Read graphics functions will be available soon.

Contact information

For any questions please contact guokai8@gmail.com