---
title: "Title of the project"
author: "Student name"
date: "23/01/2020"
output: 
  html_document:
    number_sections: true
    toc: true
    toc_float: true
    toc_depth: 3
---

<style>
body {
font-size: 13pt;
text-align: justify}
</style>

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE) #echo TRUE as default
```

# Typing # at the start creates a title for a section

First of all, **KNIT** this document with the button available on the screen. It will generate a HTML file with the output of this script.  

Here you can introduce text as normal. For a paragraph jump, use two spaces at the end.  
Notice there are two spaces here at the end.->   
In this line we don't end with spaces, so there is no paragraph jump when knitting.
With the - you can create bullet points:  

- Anywhere in the text, use **for bold**.  
- Anywhere in the text, use *for italics*.  
- Anywhere in the text, use [for webpages](http://rmarkdown.rstudio.com).  
- Again, remember to use two spaces at the end of the paragraph for a paragraph jump.  

This is the logo of RMarkdown:
You can upload images to RMarkdown from internet links using exclamation sign and squared brackets and the link to the image in normal brackets. ![use this procedure](https://secure.meetupstatic.com/photos/event/9/f/8/600_476522552.jpeg)   


## Use two ## to create a subsection

With the **chunks** we can add code to the text. The chunks are these grey boxes you will find through this RMarkdown script. Inside the chunks we place the R code. If you want to create new chunks:  

- You can select some chunk below and copy paste it.  
- Or alternatively, type in your keyboard Ctrl + Alt + I (OS X: Cmd + Option + I).  

The first chunk in a RMarkdown document normally loads the packages we are going to use. 

- The first chunk will be named *packages*. Inside the chunk, we load *dplyr* and *ggplot2*.  

```{r packages}
library(dplyr)
library(ggplot2)
```

Look at how the document is KNITTED. You can see that the package load displays all the messages that appear in the console. We need to see this in the final document, so let's remove it:  

- We will change the chunk packages.  
- After the word *packages*, add message = FALSE.  
- It should appear like {r packages, message = FALSE}  
- Now KNIT it again and see the results!  

The chunk, therefore, contains the name of the chunk and also some indications on how is going to be displayed:  

- **message**: displays (TRUE) or not (FALSE) messages.   
- **warning**: displays (TRUE) or not (FALSE) warnings.
- **echo**: TRUE by default, it hides the code when changed to FALSE.  
- **eval**: TRUE by default, it hides the output when changed to FALSE. 
- **include**: TRUE by default, it hides everything when changed to FALSE.  

Now let's see some examples. In the following chunk, we want to show the code but not the output. For this reason, we have turned `eval = FALSE`. Notice that the `ticks` transform text into code format. Name this following chunk as you wish. Make sure every chunk has different names, otherwise you will not be able to KNIT the document.  

```{r here you put the title of the chunk if you want, eval = FALSE}
hello <- c("hello")
hello
glimpse(starwars)
```

Now remove the part `eval = FALSE` and **Knit** it again!  

In the next chunk, we hide the code and display the output with `echo = FALSE`. We are interested in knowing the distinct worlds of Star Wars.  

```{r code1, echo=FALSE}
unique(starwars$homeworld)
```

And finally, the next codes displays a figure. The code is not displayed, but we also want to hide the warning message. Now it's your turn:  

- Add an indication in the following chunk that would remove the `warning` message.  

```{r plot, echo=FALSE}
starwars %>%
  ggplot(aes(x = height, y = log10(mass), col = gender)) +
  geom_point() +
  theme_bw() +
  labs(title = "Height and weight of Star Wars characters, per gender",
       x = "Height", y = "Weight (log10)", col = "Gender")
```

# More info in:  

If you want to know more about RMarkdown, use these links:  

- [Bookdown](https://bookdown.org/yihui/bookdown/markdown-syntax.html#inline-formatting)
- [RMarkdown Cheat Sheet in Spanish](https://rstudio.com/wp-content/uploads/2015/03/rmarkdown-spanish.pdf)
- [Brief summary in R para ciencia de datos](https://es.r4ds.hadley.nz/r-markdown.html)

