---
title: ' R package `rrtable` '
subtitle: ' Reproducible Research with a Table of R codes '
author: ' Keon-Woong Moon '
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{rrtable}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE ,message=FALSE,warning=FALSE,comment=NA,
          fig.width=9,fig.asp=0.618,fig.align='center',out.width='70%')
```

```{r,echo= TRUE ,message=FALSE}
require(moonBook)
require(ztable)
require(rrtable)
require(ggplot2)
options(ztable.type='HTML')
```

### Introduction 

If you are a data scientist or researcher, you will certainly be interested in reproducible research. R package `rrtable` makes it possible to make reports with HTML, LaTex, MS word or MS Powerpoint formats from a table of R codes. 

 


### Package Installation 

You can install R package `rrtable` with the following command. 

```{r echo=TRUE, eval=FALSE }
if(!require(devtools)){ install.packages("devtools") }
devtools::install_github("cardiomoon/rrtable") 
```



### Package Loading 

You can load the `rrtable` package with the following R command. 

```{r echo=TRUE }
require(rrtable) 
```



### Sample Data 

Sample data sampleData3 is included in rrtable package. You can see the sampleData3 by following R command. 

```{r echo=TRUE, eval=TRUE }
str(sampleData3) 
```



### Paragraph 

You can make a paragraph with this data 

```{r,results='asis'}
df2flextable2( sampleData3 ,vanilla= FALSE )
```



### mytable object 

You can add mytable object with the following R code. 

```{r,results='asis'}
mytable2flextable( mytable(Dx~.,data=acs) ,vanilla= FALSE )
```



### Plot 

You can insert a plot into your document. 

```{r  }
plot(Sepal.Width~Sepal.Length,data=iris) 
```



### ggplot 

You can insert a ggplot into a document 

```{r  }
ggplot(iris,aes(x=Sepal.Length,y=Sepal.Width,color=Species))+ geom_point() 
```



### R code 

You can insert the result of R code. For example, you can insert the result of regression analysis. 

```{r,echo=TRUE}
fit=lm(mpg~wt*hp,data=mtcars)
summary(fit) 
```



### Two ggplots 

You can insert two parallel ggplots with the following code. 

```{r,out.width='45%',fig.align='default',fig.show='hold'}
ggplot(iris,aes(Sepal.Length,Sepal.Width))+geom_point()
ggplot(iris,aes(Sepal.Length,Sepal.Width,colour=Species))+ geom_point()+guides(colour=FALSE) 
```



### Two plots 

You can insert two parallel plots with the following code. 

```{r,out.width='45%',fig.align='default',fig.show='hold'}
hist(rnorm(1000))
plot(1:10) 
```



### HTML Report 

You can get report with HTML format(this file) by following R command. 

```{r echo=TRUE, eval=FALSE }
data2HTML(sampleData3) 
```



### MS word document 

You can get a report with MS word format.
 

```{r echo=TRUE,eval=FALSE }
data2docx(sampleData3) 
```



You can download sample data: [sampleData3.docx](https://github.com/cardiomoon/rrtable/raw/master/inst/doc_examples/sampleData3.docx) - view with [office web viewer](https://view.officeapps.live.com/op/view.aspx?src=https://github.com/cardiomoon/rrtable/raw/master/inst/doc_examples/sampleData3.docx) 

```{r echo=TRUE,eval=FALSE }
data2docx(sampleData2) 
```



You can download sample data: [sampleData2.docx](https://github.com/cardiomoon/rrtable/raw/master/inst/doc_examples/sampleData2.docx) - view with [office web viewer](https://view.officeapps.live.com/op/view.aspx?src=https://github.com/cardiomoon/rrtable/raw/master/inst/doc_examples/sampleData2.docx) 



### MS Powerpoint document 

You can get a report with MS word format. 

```{r echo=TRUE,eval=FALSE }
data2pptx(sampleData3)  
```



You can download sample data: [sampleData3.pptx](https://github.com/cardiomoon/rrtable/raw/master/inst/doc_examples/sampleData3.pptx) - view with [office web viewer](https://view.officeapps.live.com/op/view.aspx?src=https://github.com/cardiomoon/rrtable/raw/master/inst/doc_examples/sampleData3.pptx) 

```{r echo=TRUE,eval=FALSE }
data2pptx(sampleData2) 
```



You can download sample data: [sampleData2.pptx](https://github.com/cardiomoon/rrtable/raw/master/inst/doc_examples/sampleData2.pptx) - view with [office web viewer](https://view.officeapps.live.com/op/view.aspx?src=https://github.com/cardiomoon/rrtable/raw/master/inst/doc_examples/sampleData2.pptx) 



### pdf document 

You can get a report with pdf format.  

```{r echo=TRUE,eval=FALSE }
data2pdf(sampleData3) 
```



You can download sample data: [sampleData3.pdf](https://github.com/cardiomoon/rrtable/raw/master/inst/doc_examples/sampleData3.pdf) 

```{r echo=TRUE,eval=FALSE }
data2pdf(sampleData2)  
```



You can download sample data: [sampleData2.pdf](https://github.com/cardiomoon/rrtable/raw/master/inst/doc_examples/sampleData2.pdf) 
