R Markdown Beamer Slides"

# Markdown Syntax
# - FORMAT  : *italic*, **bold**, `code`, ~subscript~, ^superscript^, > quote, ^[footnote] # - [](hyperlink)
# - EQUATION: $inline equation$, $$display equation$$, \begin{equation} (\#eq:eq-label)\end(equation), \@ref(eq:eq-label)
# - CITATION: [@bib-entry1; @bib-entry2]
# - FIGURE  : ![](image link), knitr::include_graphics(), \@ref(fig:fig1)
# - TABLE   : knitr::kable(), \@ref(tab:tab1)
# - COLUMS: 
# ::: columns
# 
# :::: column
# :::: {.column width=.7}
# left
# ::::
# 
# :::: column
# right
# ::::
# 
# :::
# - NOTES:
# :::notes
# :::
# - HIDEN:
# \invisible{
# hidden texts.
# }
# - INCREMENTAL:
# > - Eat eggs
# > - Drink coffee

Introduction


This template intends to show

  1. how to work with (R) markdown,
  2. how to make beamer slides with R markdown, and
  3. how to use shared resources in an rosr project.

If you are now using RStudio, click the button 'Knit', and you can see three options beginning with 'Knit to ...'. Try them one by one. Yeah, it can create slides, a word document, and a web page with the same contents.

Basic

Fonts

italic

bold

code

Superscript: mc^2^

Subscript: CO~2~

Hyperlinks

Hyperlink

Items

  1. Numbered items
    1. Lower levels
    2. Lower levels
  2. Numbered items

  3. Unnumbered items

  4. Lower levels
  5. Lower levels
  6. Unnumbered items

Code block

x = 1

Quates

quote

Footnotes

A footnotes can be created like this: footnote^[This is a footnote 1].

Or like this: another footnote[^footnote2]

[^footnote2]: This is another footnote.

Intermediate

Images

An image can be inserted directly like this:

![](https://openr.netlify.com/img/banners/logo-rosr.png)

If you need customized images, especially cross-reference for the image like Figure \@ref(fig:image1), use R scripts like this:

(ref:image1) This is a caption of an image.

if(file.exists('logo-rosr.png')){
  knitr::include_graphics('logo-rosr.png')  # insert a local image
} else{
  plot(1) # plot an image.
}

Tables

Insert a table with basic markdown like this:

column1 column2


row1 row1 row2 row2


or use scripts like Table \@ref(tab:tab1):

(ref:tab1) This is the caption of a table.

knitr::kable(head(cars), booktabs = TRUE, 
             caption = "(ref:tab1)")

Equations

An inline equation is like this:$F(x) = \int^a_b \frac{1}{3}x^3$.

An display equation can be inserted like this:

$$F(x) = \int^a_b \frac{1}{3}x^3$$

If an equation should be numbered or cross-referred, insert it like Equation \@ref(eq:eqtest) for pdf and html:

\begin{align} F(x) = \int^a_b \frac{1}{3}x^3 (#eq:eqtest) \end{align}

and Equation (@eq-mc) for Word.

(@eq-mc) $F(x) = \int^a_b \frac{1}{3}x^3$

Citation

Suppose you have a .bib file named 'rosr.bib' (See bibliography: in the YALM header). If not, you can create a bib file like this.

knitr::write_bib(c('knitr', 'rosr'), file = 'rosr.bib')

Now insert citations like this: @R-knitr, [@R-knitr;@R-rosr].

Numbers

temperature <- 17

We can use the results. For example, the mean temperature is r temperature degree.

Advanced

Columns and notes

Split one slide into two columns like this:

::::columns :::column

This is the left column

::: :::column

This is the right column ::: ::::

Insert notes like this:

:::notes

Choose the right option for notes: in the YAML header of this template. :::

and vertical spaces

Insert vertical spaces like this:

\vspace{\baselineskip}

Create columns with different widths like this:

\vspace{3\baselineskip}

::::columns ::: {.column width=.3}

This is a narrow column.

:::

::: {.column width=.7}

This is a wide one.

::: ::::

\vspace{.5in}

'in' means 'inches'.

Invisable texts

Insert invisable texts like this:

\invisible{

Hidden texts.

}

In a 'rosr' project

The codes in this section are all commented, for non-'rosr' project. But if you are organizing a 'rosr' project with, you can share resources easily between manuscripts, slides, posters, and so on. In a 'rosr' project, images are placed in the 'image' folder, bibliography in the 'bib' folder, R scripts in the 'R' folder, and equations in the 'equation' folder. If this is in a 'rosr' project, uncomment the following codes and try.


Firstly, we save the working directory. switch off the warning and message display in a manuscript if you want.

# oldwd <- getwd()
# knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)

set the root dir as the project directory, syc the bibliography and load data or functions within the project.

# knitr::opts_knit$set(root.dir = dirname(dirname(oldwd)))
# file.copy('bib/rosr.bib', oldwd)
# source('R/rosr.R')

If you load the 'rosr' package,

# require('rosr')

an image could be inserted like this:

# fig('rosr_R.png')

and an equation could be inserted like this:

# eqs <- 'equation/rosr-eq.Rmd'
# eq(eqs, label = 'sd')

References



Try the rosr package in your browser

Any scripts or data that you put into this service are public.

rosr documentation built on July 2, 2020, 2:28 a.m.