Diferenças
Aqui você vê as diferenças entre duas revisões dessa página.
Ambos lados da revisão anteriorRevisão anteriorPróxima revisão | Revisão anterior | ||
projetos:reproducibleresearch [2014/03/17 17:50] – [Reproducible Research] joel | projetos:reproducibleresearch [2014/03/17 18:04] (atual) – [Reproducible Research] joel | ||
---|---|---|---|
Linha 5: | Linha 5: | ||
< | < | ||
- | ## @knitr | + | # loaddata |
data(iris) | data(iris) | ||
- | ## @knitr | + | # summarydata |
summary(iris) | summary(iris) | ||
- | ## @knitr | + | # boxplot |
boxplot(iris[, | boxplot(iris[, | ||
- | ## @knitr | + | # table |
table(iris[, | table(iris[, | ||
+ | |||
+ | </ | ||
+ | |||
+ | We can embbed those commands into a simple LaTeX file according to the example below : | ||
+ | |||
+ | < | ||
+ | \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} | ||
+ | << | ||
+ | # loading data set | ||
+ | data(iris) | ||
+ | @ | ||
+ | |||
+ | |||
+ | \section{Summary of Data} | ||
+ | << | ||
+ | # summary of the data set | ||
+ | summary(iris) | ||
+ | @ | ||
+ | |||
+ | \section{A Box Plot} | ||
+ | << | ||
+ | # building a box plot | ||
+ | boxplot(iris$Sepal.Length~iris$Species) | ||
+ | @ | ||
+ | |||
+ | |||
+ | \section{A Table} | ||
+ | |||
+ | << | ||
+ | # loading xtable package | ||
+ | require(xtable) | ||
+ | |||
+ | # creating a table | ||
+ | tab< | ||
+ | |||
+ | # buiding a table with all data | ||
+ | print(xtable(tab)) | ||
+ | @ | ||
+ | |||
+ | \section{Aditional Tips} | ||
+ | |||
+ | <<>> | ||
+ | # let it commented | ||
+ | # purl(" | ||
+ | # system(" | ||
+ | @ | ||
+ | |||
+ | \end{document} | ||
</ | </ | ||
+ | |||
+ | Save the commands above into a file called report.rnw and compile it into a LaTeX document according to the commands below. | ||
+ | |||
+ | < | ||
+ | library(knitr) | ||
+ | knit(" | ||
+ | </ | ||
+ | |||
+ | This will generate a .tex file that can be processed by a LaTex editor! | ||
+ | |||
+ | For linux and mac users, you can run : | ||
+ | |||
+ | < | ||
+ | > tex2pdf report.tex | ||
+ | </ | ||
+ | |||
+ | to convert the result into a pdf | ||
+ | |||
+ |