title: "Show Your Webcam in R Markdown Presentations" author: "Yihui Xie" date: "2015/10/25" output: slidy_presentation: incremental: yes duration: 40 footer: "Webcam in R Markdown, Yihui Xie, 2015" includes:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Developer Certificate of Origin | |
Version 1.1 | |
Copyright (C) 2004, 2006 The Linux Foundation and its contributors. | |
1 Letterman Drive | |
Suite D4700 | |
San Francisco, CA, 94129 | |
Everyone is permitted to copy and distribute verbatim copies of this | |
license document, but changing it is not allowed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(xml2) | |
page_post_links = function( | |
page = 1, baseurl = 'https://www.rstudio.com/rviews', | |
xpath = '//h2[@class="entry-title"]/a' | |
) { | |
html = read_html(sprintf('%s/page/%d/', baseurl, page)) | |
xml_attr(xml_find_all(html, xpath), 'href') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# you can replace $HOME with any dir | |
sed -i 's@\$TEXLIVEHOME@'"$HOME"'@' texlive.profile | |
wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz | |
tar zxf install-tl-unx.tar.gz | |
./install-tl*/install-tl -profile texlive.profile | |
# texlive.tar.gz is a portable and full TeXLive package | |
tar zcf texlive.tar.gz -C $HOME texlive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: HTML Dependencies | |
output: html_document | |
--- | |
This example explains how HTML dependencies work in **htmltools**. Sometimes an HTML fragment may have additional dependencies to work correctly, such as JavaScript and/or CSS files. In R Markdown documents, you have to let **rmarkdown** know these dependencies, so they can be added to the HTML header when the document is rendered through Pandoc. | |
Another thing that you need to pay attention is you have to "protect" your HTML output so that Pandoc does not touch it, e.g. when you have four leading spaces, Pandoc may think this line is supposed to be a `<pre>` block whereas you only meant to indent the line for cosmetic purposes. In this case, the function `htmltools::htmlPreserve()` will be _automatically_ applied to your HTML content in R Markdown if the content is generated from `htmltools::tags` or wrapped in `htmltools::HTML()`. | |
Now we use a random CSS file in the **knitr** package to illustrate how dependencies work. The goal here is to generate a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\begin{document} | |
<<setup, include=FALSE, cache=FALSE>>= | |
library(knitr) | |
library(ggplot2) | |
@ | |
\title{Knitr and ggplot2} | |
\author{Daniel Haugstvedt} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here is a list of package vignettes _possibly_ built with **knitr** on CRAN. | |
```{r fetch-pkgs, include=FALSE} | |
pkgs = available.packages(contrib.url('https://cran.r-project.org', 'source')) | |
deps = tools::package_dependencies('knitr', pkgs, which = 'all', reverse = TRUE)[['knitr']] | |
deps = setdiff(deps, 'R.rsp') # packages that do not use knitr | |
deps = sort(c(deps, 'knitr')) | |
``` | |
```{r vig-list, include=FALSE, echo=FALSE, cache=TRUE, cache.extra=deps, message=FALSE, error=FALSE} | |
vigs = lapply(deps, function(pkg) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
options(warn = -1) | |
# cannot really suppress warnings from the root level | |
withCallingHandlers(warning("hi"), warning = function(w) { | |
print(w) | |
}) | |
# the warning can still be captured: | |
## <simpleWarning in withCallingHandlers(warning("hi"), warning = function(w) { print(w)}): hi> | |
# however, this always works |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stopifnot(getRversion() > '3.0.1') | |
par("page") | |
dev.off() | |
dev.new() | |
par("page") | |
plot(1) | |
par("page") |
NewerOlder