rrtableReproducible Research with a Table of R codes
Keon-Woong Moon
2018-04-15
require(moonBook)require(ztable)require(rrtable)require(ggplot2)If you are a data scientist or researcher, you will certainly beinterested in reproducible research. R packagerrtablemakes it possible to make reports with HTML, LaTex, MS word or MSPowerpoint formats from a table of R codes.
You can install R packagerrtable with the followingcommand.
if(!require(devtools)){install.packages("devtools") }devtools::install_github("cardiomoon/rrtable")You can load therrtable package with the following Rcommand.
require(rrtable)Sample data sampleData3 is included in rrtable package. You can seethe sampleData3 by following R command.
str(sampleData3)'data.frame': 15 obs. of 5 variables: $ type : chr "title" "subtitle" "author" "text" ... $ title : chr "" "" "" "Introduction" ... $ text : chr "R package `rrtable`" "Reproducible Research with a Table of R codes" "Keon-Woong Moon" "If you are a data scientist or researcher, you will certainly be interested in reproducible research. R package"| __truncated__ ... $ code : chr "" "" "" "" ... $ option: chr "" "" "" "" ...You can make a paragraph with this data
df2flextable2( sampleData3 ,vanilla=FALSE )
| ||||
| ||||
| ||||
| ||||
fit=lm(mpg~wt*hp,data=mtcars)summary(fit) | ||||
You can add mytable object with the following R code.
mytable2flextable(mytable(Dx~.,data=acs) ,vanilla=FALSE )You can insert a plot into your document.
hist(rnorm(1000))
You can insert a ggplot into a document
ggplot(iris,aes(x=Sepal.Length,y=Sepal.Width,color=Species))+geom_point()
You can insert the result of R code. For example, you can insert theresult of regression analysis.
fit=lm(mpg~wt*hp,data=mtcars)summary(fit)Call:lm(formula = mpg ~ wt * hp, data = mtcars)Residuals: Min 1Q Median 3Q Max -3.0632 -1.6491 -0.7362 1.4211 4.5513 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 49.80842 3.60516 13.816 5.01e-14 ***wt -8.21662 1.26971 -6.471 5.20e-07 ***hp -0.12010 0.02470 -4.863 4.04e-05 ***wt:hp 0.02785 0.00742 3.753 0.000811 ***---Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1Residual standard error: 2.153 on 28 degrees of freedomMultiple R-squared: 0.8848, Adjusted R-squared: 0.8724 F-statistic: 71.66 on 3 and 28 DF, p-value: 2.981e-13You can insert two parallel ggplots with the following code.
ggplot(iris,aes(Sepal.Length,Sepal.Width))+geom_point()ggplot(iris,aes(Sepal.Length,Sepal.Width,colour=Species))+geom_point()+guides(colour=FALSE)

You can insert two parallel plots with the following code.
hist(rnorm(1000))plot(1:10)

You can get report with HTML format(this file) by following Rcommand.
data2HTML(sampleData3)You can get a report with MS word format.
data2docx(sampleData3)You can download sample data:sampleData3.docx- view withofficeweb viewer
data2docx(sampleData2)You can download sample data:sampleData2.docx- view withofficeweb viewer
You can get a report with MS word format.
data2pptx(sampleData3)You can download sample data:sampleData3.pptx- view withofficeweb viewer
data2pptx(sampleData2)You can download sample data:sampleData2.pptx- view withofficeweb viewer
You can get a report with pdf format.
data2pdf(sampleData3)You can download sample data:sampleData3.pdf
data2pdf(sampleData2)You can download sample data:sampleData2.pdf