Created
August 13, 2012 11:55
-
-
Save 1beb/3339966 to your computer and use it in GitHub Desktop.
Example of reproducible research in Rstudio documents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setwd('path/to/Example.Rnw/') | |
| Sweave('Example.Rnw') | |
| texi2pdf('Example.tex') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % Preamble | |
| \documentclass{Article} | |
| \usepackage{Sweave} | |
| % Start Document | |
| \begin{document} | |
| % Titlepage | |
| \begin{titlepage} | |
| \title{A Title} | |
| \author{Author's Name} | |
| \date {\today} | |
| \maketitle | |
| \end{titlepage} | |
| % Content Begins | |
| \section{A Linear Regression} | |
| Here, we generate some sample data. By default, sweave echoes the results - showing | |
| us what commands are run in R. But we can stop that in our code chunk by specifying | |
| "echo=FALSE". In the example below, we will generate random variables from the | |
| normal and uniform distribution, put them in a data frame, run a linear regression | |
| and output a table that shows us the pertinent information from the regression. | |
| % R Code Chunk | |
| <>= | |
| library(xtable) | |
| set.seed(1234) # Set seed for RNG | |
| x >= | |
| plot(fit, which=1) | |
| @ | |
| % End Document | |
| \end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment