class: center, middle, inverse, title-slide # R Markdown ## Practical 3 ### PAAS --- ## Today - Q&A about last week's tutorial and practical - Intro to R Markdown - Basic markdown - YAML - Including images, GIFs, URLs - Attendance - Small group activity with worksheet --- ## What is R Markdown - R Markdown (Rmd) is `R`'s version of markdown - markdown is a markup language; all clear? :P - markdown is just a language for writing documents **using only plain text** - Unlike WYSIWYG editors, it separates form from content - Rmd combines markdown with `R` code - Lets you put results of `R` code directly into your documents - Tables, plots, analysis results - You can use it to create all sorts of things - text documents - web pages - blogs - presentations - dissertation - teaching materials (like we do) --- ## Basic markdown
# Level 1 heading ## Level 2 heading ### Level 3 heading, etc.. This is **bold**. This is __also bold__. This is *italics* and _so is this_. If you really want, you can also do ~~strikethrough~~.
<script type="text/javascript"> document.body.onload = build; function build (){ let scriptTag = document.createElement('script'); scriptTag.src = './js/main.js'; document.body.appendChild(scriptTag); } </script> --- ## Basic markdown
One line break doesn't do anything. These two sentences are still in the same paragraph. For a new paragraph, we need two line breaks. - this is - an *unordered* - list - it can have - multiple levels 1. this is 1. an *ordered* 1. list 1. also with 1. multiple levels
<script type="text/javascript"> document.body.onload = build; function build (){ let scriptTag = document.createElement('script'); scriptTag.src = './js/main.js'; document.body.appendChild(scriptTag); } </script> --- ## YAML header - It's necessary for every R Markdown file - YAML stands for _Yet Another Markup Language_ (no kiddin'!) - **ALWAYS** "fenced-off" by ` --- ` _on either side!_ - Must include at least **`title`** and **`output`** - Can contain other fields ``` --- title: "Nicolas Cage fanclub pages" subtitle: "Unofficial club for the NC aficionados" author: "Coppolas Nicola" date: "7 January 1964" output: html_document --- ``` --- ## Images from your computer ```  ``` <img width="70%" src="./assets/total_babe.jpg" /> --- ## Images from the webs ```  ``` <img width="70%" src="https://www.indiewire.com/wp-content/uploads/2019/09/10324474a.jpg" /> --- ## GIFs? GIFs! ```  ```  --- ## URL (links) ``` Nic's Wikipedia page is <https://en.wikipedia.org/wiki/Nicolas_Cage> ``` Nic's Wikipedia page is <https://en.wikipedia.org/wiki/Nicolas_Cage> <br><br> ``` Nic's [IMDB page](https://www.imdb.com/name/nm0000115/) ``` Nic's [IMDB page](https://www.imdb.com/name/nm0000115/) --- ## Learning Rmd - Always compare source (.Rmd) and outcome (.html, .docx, .pdf) - Pay attention to details - Spaces matter - Line breaks matter - Use online resources! - [R Markdown cheat sheet](https://raw.githubusercontent.com/rstudio/cheatsheets/master/rmarkdown-2.0.pdf) - [R Markdown: The Definitive Guide](https://bookdown.org/yihui/rmarkdown/) --- ## `.Rmd` files - Just plain text files - The `.Rmd` file extension tells RStudio that this plain text file contains R Markdown - RStudio will make it look nice for you and give you additional options - **If you open a R Markdown file in RStudio and the text is all the same colour, the file probably doesn't have the correct `.Rmd` file extension!** - If so, you can edit the file name manually --- ## `.Rmd` vs `.txt` .pull-left[  ] .pull-right[  ] --- ## Learning Rmd - Always compare source (.Rmd) and outcome (.html, .docx, .pdf) - Pay attention to details - Spaces matter - Line breaks matter - Use online resources! - [R Markdown cheat sheet](https://raw.githubusercontent.com/rstudio/cheatsheets/master/rmarkdown-2.0.pdf) - [R Markdown: The Definitive Guide](https://bookdown.org/yihui/rmarkdown/) --- ## Attendance - Use the Sussex app or go to <https://sussex.ombiel.co.uk/> - Enter PIN --- ## Over to you! - Go to [Canvas > PAAS > Syllabus > Week 4 > Practical > Worksheet](https://canvas.sussex.ac.uk/courses/12684/pages/week-4) - Try working together as a group - Ask for help if you need to (bottom menu panel)