SharedPublic / r-beamer-demo.RmdOpen in CoCalc
Create Beamer slides with R markdown - Rmd
title: Rmd Beamer Example
author: John Doe
date: July 9, 2018
# Example of Beamer Slides from R Markdown

## Outline

- Instructions
- An image
- Two R code chunks
- An equation typeset in LaTeX
- References

## How to Create Beamer Slides from an Rmd file

- put title information in yaml prologue (optional)
- open a `.term` file and run these commands
- rendered view in Rmd editor may not look right - view the pdf file to see slides

  $ R
  > library(rmarkdown)
  > render("filename.Rmd", beamer_presentation())
  > quit()
  $ open filename.pdf

## Image

![NASA Exoplanet Exploration Program](figure/exoplanet_exploration.jpg)

## LaTeX

Radius of planet: $$r_p=r_s{\times}{\sqrt{\frac{{\Delta}B}{B}}}$$

Radius of planet's orbit: $$r=\sqrt[3]{\frac{G{M_s}{P^2}}{4{{\pi}^2}}}$$

## R Code Chunk 1

Get Data

```{r fetch_data}
qry  <- paste0("table=exoplanets&select=",
site <- paste0("",
url <- paste0(site, "?", qry)
exo <- read.csv(url, stringsAsFactors=F)
exo$pl_discmethod <- as.factor(exo$pl_discmethod)

## R Code Chunk 2

Yield for different methods of discovery.
Use log scale on vertical axis

```{r plot_discmethod_logscale, echo=F}
exot <- table(exo$pl_discmethod)
exoto <- exot[order(exot,decreasing = T)]

par(mar=c(12.5,3,3.5, 0.3), cex.main=1.5)
  main="Exoplanets Discovered vs. Method",
  log="y", ylim=c(1,3000))

## References

Beamer User Guide

R Markdown Presentations with Beamer

R function to create beamer slides

NASA Exoplanet Exploration Program