Skip to content

Instantly share code, notes, and snippets.

@malcolmbarrett
Created May 24, 2019 22:01
Show Gist options
  • Select an option

  • Save malcolmbarrett/97315963a2ee56e4df21286b265a4399 to your computer and use it in GitHub Desktop.

Select an option

Save malcolmbarrett/97315963a2ee56e4df21286b265a4399 to your computer and use it in GitHub Desktop.
---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
xaringan::moon_reader:
css: ["default", "hiddencloud"]
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
class: hiddencloud
# Some Tips
An example of using the trailing comment `#<<` to highlight lines:
````markdown
`r ''````{r tidy=FALSE}
library(ggplot2)
ggplot(mtcars) +
aes(mpg, disp) +
geom_point() + #<<
geom_smooth() #<<
```
````
Output:
```{r tidy=FALSE, eval=FALSE, }
library(ggplot2)
ggplot(mtcars) +
aes(mpg, disp) +
geom_point() + #<<
geom_smooth() #<<
```
---
class: hiddencloud
# Some Tips
When you enable line-highlighting, you can also use the chunk option `highlight.output` to highlight specific lines of the text output from a code chunk. For example, `highlight.output = TRUE` means highlighting all lines, and `highlight.output = c(1, 3)` means highlighting the first and third line.
````md
`r ''````{r, highlight.output=c(1, 3)}
head(iris)
```
````
```{r, highlight.output=c(1, 3), echo=FALSE}
head(iris)
```
Question: what does `highlight.output = c(TRUE, FALSE)` mean? (Hint: think about R's recycling of vectors)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment