RTemplate - R Markdown Template for Analysis
Download zip file from internet
recipes_data_dir <- tempdir()
s2_zip <- tempfile(fileext = ".zip")
download.file(url = "https://media.nature.com/original/nature-assets/srep/2011/111215/srep00196/extref/srep00196-s2.zip", destfile = s2_zip)
unzip(s2_zip, exdir = recipes_data_dir)
Include graphics
- output: pdf_document
{r rmarkdown, out.width="0.5\\textwidth"}
knitr::include_graphics("images/rmarkdown-sticker.png")
- output: html_document
{r rmarkdown-sticker, out.width="50%"}
knitr::include_graphics("images/rmarkdown-sticker.png")
Insert images using HTML
Here's the logo for Rmarkdown
<img src='images/rmarkdown-sticker.png' style='width:50%;min-width:300px'></img>
- Use rvest
{r get-google-doodle-url}
library("tidyverse")
library("rvest")
library("glue")
google_doodles_page <- read_html("https://www.google.com/doodles")
doodle_url <- google_doodles_page %>%
html_node(".latest-doodle") %>%
html_node("img") %>%
html_attr("src") %>%
str_replace("//", "")
doodle_url
download.file(url = doodle_url,
destfile = "images/google-doodle.png")
- Raw markdown
- knitr::kable()
- DT::datatable() -> interactive
library("tidyverse")
library("fivethirtyeight")
library("DT")
bechdel %>%
filter(year > 1990) %>%
select(title, year, clean_test, binary, intgross_2013) %>%
arrange(desc(intgross_2013)) %>%
slice(1:20) %>%
datatable(filter="top")
output:
pdf_document:
toc: true
df_print: kable
html_document:
toc: true
df_print: kable
output:
html_document:
df_print: paged
css file
- 10.2, 10.3