Não foi possível enviar o arquivo. Será algum problema com as permissões?
Diferenças
Aqui você vê as diferenças entre duas revisões dessa página.
Próxima revisão | Revisão anterior Próxima revisão Ambos lados da revisão seguinte | ||
projetos:reproducibleresearch [2014/03/17 17:48] joel [section 1] |
projetos:reproducibleresearch [2014/03/17 17:56] joel [Reproducible Research] |
||
---|---|---|---|
Linha 1: | Linha 1: | ||
====== Reproducible Research ====== | ====== Reproducible Research ====== | ||
+ | |||
+ | In this page we show how to create a minimal report using R + Latex + Markdown Resources. Lets create a minimal report from few R commands : | ||
+ | |||
+ | <code> | ||
+ | # loaddata | ||
+ | data(iris) | ||
+ | |||
+ | # summarydata | ||
+ | summary(iris) | ||
+ | |||
+ | # boxplot | ||
+ | boxplot(iris[,1]~iris[,5]) | ||
+ | |||
+ | # table | ||
+ | table(iris[,5]) | ||
+ | |||
+ | </code> | ||
+ | |||
+ | We can embbed those commands into a simple LaTeX file according to the example below : | ||
+ | |||
+ | <code> | ||
+ | \documentclass{article} | ||
+ | |||
+ | \title{Introduction to Reproducible Research in R} | ||
+ | \author{Bioinformatics Meeting} | ||
+ | |||
+ | |||
+ | \begin{document} | ||
+ | |||
+ | \maketitle | ||
+ | |||
+ | \section{Introduction} | ||
+ | |||
+ | This document contains a minimal example of reproducible research using R. | ||
+ | |||
+ | \section{Loading Data} | ||
+ | <<loaddata>>= | ||
+ | # loading data set | ||
+ | data(iris) | ||
+ | @ | ||
+ | |||
+ | |||
+ | \section{Summary of Data} | ||
+ | <<summarydata>>= | ||
+ | # summary of the data set | ||
+ | summary(iris) | ||
+ | @ | ||
+ | |||
+ | \section{A Box Plot} | ||
+ | <<results='hide',boxplot,fig.show='hide'>>= | ||
+ | # building a box plot | ||
+ | boxplot(iris$Sepal.Length~iris$Species) | ||
+ | @ | ||
+ | \includegraphics{figure/boxplot.pdf} | ||
+ | \section{A Table} | ||
+ | |||
+ | <<table,results='asis'>>= | ||
+ | # loading xtable package | ||
+ | require(xtable) | ||
+ | |||
+ | # creating a table | ||
+ | tab<-table(iris$Species) | ||
+ | |||
+ | # buiding a table with all data | ||
+ | print(xtable(tab)) | ||
+ | @ | ||
+ | |||
+ | \section{Aditional Tips} | ||
+ | |||
+ | <<>>= | ||
+ | # let it commented | ||
+ | # purl("report.rnw") | ||
+ | # system("pandoc -s report.tex -o report.docx") | ||
+ | @ | ||
+ | |||
+ | \end{document} | ||
+ | |||
+ | </code> | ||
+ | |||
+ | Save this file as report.Rnw and run in R the following commands : | ||
+ | |||
+ | <code> | ||
+ | library(knitr) | ||
+ | knit("report.rnw") | ||
+ | system("tex2pdf report.tex") | ||
+ | </code> | ||
+ | |||
+ |