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. 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.
``` {r install,eval = FALSE}
### 2.2 Load package ```r library(eoffice) library(ggplot2)
-- topptx write figures to powerpoint file.
-- todocx write figures to word file.
-- totable write data frame or summary results of different model to powerpoint or word files
-- indocx read tables from word file
-- inpptx read tables from powerpoint file
-- tofigure write figures to different output formats.
-- tohtml write figures to interactive html file
-- infigure read figures or pdf files into R and extract colors from these files.
Please install imageMagick to use the _infigure_ function. On Linux you need to install the ImageMagick++ library: on Debian/Ubuntu this is called libmagick++-dev: sudo apt-get install libmagick++-dev On Fedora or CentOS/RHEL we need ImageMagick-c++-devel: sudo yum install ImageMagick-c++-devel
``` {r fig2, fig.width = 6, fig.height = 5, fig.align = "center"} plot(mtcars$mpg, mtcars$disp, col = factor(mtcars$cyl), pch = 20) topptx(filename = file.path(tempdir(), "mtcars.pptx"))
ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) + geom_point() topptx(filename = file.path(tempdir(), "mtcars.pptx"))
p <- ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) + geom_point() topptx(p, filename = file.path(tempdir(), "mtcars.pptx"), width = 6, height = 4)
totable(head(mtcars), filename = file.path(tempdir(), "mtcars.pptx")) totable(head(mtcars), filename = file.path(tempdir(), "mtcars.pptx"))
tt <- t.test(wt ~ am, mtcars) totable(tt, filename = file.path(tempdir(), "mtcars.pptx")) totable(t.test(wt ~ am, mtcars), filename = file.path(tempdir(), "mtcars.pptx"))
tabs <- inpptx(filename = file.path(tempdir(), "mtcars.pptx"), header = TRUE)
p <- ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) + geom_point() tofigure(p, filename = file.path(tempdir(), "mtcars.pdf")) tofigure(ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) + geom_point(), filename = file.path(tempdir(), "mtcars.eps"))
```
eoffice mainly 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.
For any questions please contact guokai8@gmail.com
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.