This quick start guide is intended to assist you to hand in your monitoring proofs with Markdown and R-studio. It contains the basics to prepare a document including the code and the R
output. The final document will include the contents of the monitoring proof in an appropriate and smart style.
To prepare the monitoring proofs or any other homework in this format you need to install first R and RStudio with the packages knitr y rmarkdown
The files to produce R Markdown
documents have extension .Rmd
.
The files need to be opened with RStudio
and it is compiled by clicking on the knitr
button.
The result is a document in .pdf
, .html
, or .doc
format.
The file Example1.Rmd
Hola, soy __R Markdown__
Mírame [aquí](http://rmarkdown.rstudio.com/)
creates, by cliking on knitr to HTML
a .html
file with this content
Hi, I am R Markdown
Look at me here
Let us check the most important parts of the Rmd
document.
It is on the upper part of the document within these two lines ---
---
title: "Write your title here"
author: "Write your name here"
date: "Write the date here"
output:
pdf_document: default
html_document: default
word_document: default
---
In the file header you have to write the title of the document, your name, and the date. The output statement is used for the class of the final document, pdf ,
htmlor
doc. We will use
.pdf`. To produce a pdf file you need to install MikTeX.
Next, we set the required options to print the R
code and the R output in the final document.
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
The first line is to hide this piece of code in the final document.
The second line is to print the R code and the R
output in the final document.
Plain text is written like in any other document like a word document. You should be careful about italic or bold letters and some special characters. For example
Bold: Write your text within **Bold**
or __Bold__
Italic: Write your text within *Italic*
or _Italic_
Section Headers
# Títle 1
## Títle 2
### Títle 3
The more symbols # you write before your text, the smaller the size of your title
You can find more information about writing in the following file
R
codeR
code is inserted using the following lines
```{r}
write your code
```
It can be automatically inserted by clicking on the Insert button (select R) in RStudio
. In the .Rmd
file you only have to write the R code. The output of the code is generated when you compile the document.
To compile the .Rmd
file and get your final document, just click on the Knit button and select Knit to PDF to produce a .pdf
file.
---
title: "Write your title here"
author: "Write your name here"
date: "Write the date here"
output:
pdf_document: default
html_document: default
word_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
<The text within these two symbols does not appear in the final documents. Use it to write your comments>
## Problem 1
The data base `CARS2004` of the package `PASWR2` contains the numbers of cars per 1000 inhabitants (`cars`), the total number of known mortal accidents (`deaths`), and the country population/1000 (`population`) for the 25 member countries of the European Union for the year 2004
1. Summarize the data using `R`.
2. Use the `eda` function in package `PASWR2` to conduct an exploratory analysis of variable `deaths`
### Item 1
```{r}
library(PASWR2)
summary(CARS2004)
```
You can observe that the `R` code and the output of the analysis appear when you compile the document.
### Item 2
Use the `eda` function in package `PASWR2` to conduct an exploratory analysis of variable `deaths`
```{r}
eda(CARS2004$deaths)
```
In this case, the `R` code, the numeric output of `eda` function and the graphical output of `eda` function appear in the final document.
#Use this file to hand in your monitoring proofs in a simple and smart document.