1. Objectives & Structure

Objectives:

In this course, we are going to focus on two learning objectives:

  1. Create an R Markdown file

  2. Write and use R Markdown commands

By the end of this course, you will be able to create an R Markdown file, understand the different components of the file, knit the file as an HTML document or a pdf document, and publish the document.

Structure:

This course is divided into five (5) parts:

  1. Project Overview: This introductory reading material.

  2. Reading: R Markdown Additional Resources

  3. Get Started with R Markdown: This is the hands-on project that we will work on together in Rhyme

  4. Graded Quiz: This is the final assignment that you need to pass in order to finish the project successfully.

  5. Course End (Learner) Survey: Tell us what you thought about this guided project!

2. R Markdown Additional Resources

Click on this link to read the article written by RStudio about R Markdowns.

Also, RStudio developers have produced an R Markdown Cheatsheet.

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

3. Knit to PDF

tinytex::install_tinytex(force = TRUE)
## The directory /usr/local/bin is not writable. I recommend that you make it writable. See https://github.com/rstudio/tinytex/issues/24 for more info.
## tlmgr install tlgpg
## tlmgr update --self
## tlmgr install tlgpg
## tlmgr --repository http://www.preining.info/tlgpg/ install tlgpg
## tlmgr option repository 'https://mirror.kku.ac.th/CTAN/systems/texlive/tlnet'
## tlmgr update --list

4. In đậm, in nghiêng

Knit: in đậm ** Knit **

Knit: in nghiêng * Knit *

5. Create Bullete Points

Dấu gì thì nó cũng ra 1 kiểu định dạng :D

6. Including Plots & inline codes

You can also embed plots, for example:

##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Note that the echo = FALSE parameter was added to the code chunk to prevent pri?nting of the R code that generated the plot.

x <- 5 # radius of a circle 

For a circle of radius 5, its area is 78.5398163. Được viết là For a circle of radius ’‘5’‘, its area is’‘78.5398163’’

8. Insert images

First think first: you must have your image in .jpg or .png

The best way is to group all images in a folder, to be put in a directory, the directory to which RStudio has access.

To add an image in markdown you must stop text editing, and you do this with the command [Alt text] precedeed by a !

Then you have to add the path to the image in brackets.

The path to the image is the path from your directory to the image.

setwd("~/Documents/8. R skills/R_Coursera/")

Rmarkdown Rmarkdown