-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added parameterized report and revealjs
- Loading branch information
1 parent
35402b2
commit 983249e
Showing
9 changed files
with
234 additions
and
17 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: '`r paste0(params$name," report")`' | ||
subtitle: "Parameterized report" | ||
author: "John Doe" | ||
date: last-modified | ||
format: | ||
html: | ||
title-block-banner: true | ||
toc: true | ||
number-sections: true | ||
theme: pulse | ||
highlight: kate | ||
code-tools: true | ||
fig-align: left | ||
|
||
params: | ||
name: setosa | ||
--- | ||
|
||
```{r} | ||
library(ggplot2) | ||
``` | ||
|
||
```{r} | ||
#| echo: false | ||
#| output: asis | ||
cat("## ",params$name) | ||
``` | ||
|
||
The `r params$name` species is subsetted from the data. | ||
|
||
```{r} | ||
iris_filtered <- subset(iris, iris$Species == params$name) | ||
``` | ||
|
||
```{r} | ||
head(iris_filtered) | ||
``` | ||
|
||
## Plots | ||
|
||
```{r,fig.cap="This is a scatterplot."} | ||
#| label: fig-scatterplot | ||
#| fig-cap: !expr paste0("Scatterplot of ",params$name," species.") | ||
ggplot(iris_filtered,aes(Sepal.Length,Petal.Length,col=Species))+ | ||
geom_point()+ | ||
labs(title=params$name) | ||
``` | ||
|
||
## Image | ||
|
||
```{r} | ||
#| echo: false | ||
#| label: fig-species | ||
#| fig-cap: !expr paste0("Photograph of ",params$name," species.") | ||
imgs <- c( | ||
"setosa" = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Irissetosa1.jpg/220px-Irissetosa1.jpg", | ||
"versicolor" = "https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Blue_Flag%2C_Ottawa.jpg/220px-Blue_Flag%2C_Ottawa.jpg", | ||
"virginica" = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Iris_virginica_2.jpg/220px-Iris_virginica_2.jpg" | ||
) | ||
knitr::include_graphics(imgs[match("versicolor", names(imgs))]) | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
title: '`r paste0(params$name," report")`' | ||
subtitle: "Parameterized report" | ||
author: "John Doe" | ||
date: last-modified | ||
format: | ||
pdf: | ||
title-block-banner: true | ||
toc: true | ||
number-sections: true | ||
theme: pulse | ||
highlight: kate | ||
code-tools: true | ||
fig-align: left | ||
|
||
pdf-engine: pdflatex | ||
|
||
params: | ||
name: setosa | ||
--- | ||
|
||
```{r} | ||
library(ggplot2) | ||
``` | ||
|
||
```{r} | ||
#| echo: false | ||
#| output: asis | ||
cat("## ",params$name) | ||
``` | ||
|
||
The `r params$name` species is subsetted from the data. | ||
|
||
```{r} | ||
iris_filtered <- subset(iris, iris$Species == params$name) | ||
``` | ||
|
||
```{r} | ||
head(iris_filtered) | ||
``` | ||
|
||
## Plots | ||
|
||
```{r,fig.cap="This is a scatterplot."} | ||
#| label: fig-scatterplot | ||
#| fig-cap: !expr paste0("Scatterplot of ",params$name," species.") | ||
ggplot(iris_filtered,aes(Sepal.Length,Petal.Length,col=Species))+ | ||
geom_point()+ | ||
labs(title=params$name) | ||
``` | ||
|
||
## Image | ||
|
||
```{r} | ||
#| echo: false | ||
#| label: fig-species | ||
#| fig-cap: !expr paste0("Photograph of ",params$name," species.") | ||
imgs <- c( | ||
"setosa" = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Irissetosa1.jpg/220px-Irissetosa1.jpg", | ||
"versicolor" = "https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Blue_Flag%2C_Ottawa.jpg/220px-Blue_Flag%2C_Ottawa.jpg", | ||
"virginica" = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Iris_virginica_2.jpg/220px-Iris_virginica_2.jpg" | ||
) | ||
knitr::include_graphics(imgs[match("versicolor", names(imgs))]) | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
--- | ||
pagetitle: "RevealJS" | ||
title: '`r paste0(params$name," presentation")`' | ||
subtitle: "Parameterized presentation" | ||
author: "John Doe" | ||
date: last-modified | ||
format: revealjs | ||
params: | ||
name: setosa | ||
--- | ||
|
||
## Packages {visibility="hidden"} | ||
|
||
```{r} | ||
library(ggplot2) | ||
``` | ||
|
||
```{r} | ||
#| echo: false | ||
#| output: asis | ||
cat("## ",params$name) | ||
``` | ||
|
||
The `r params$name` species is subsetted from the data. | ||
|
||
```{r} | ||
iris_filtered <- subset(iris, iris$Species == params$name) | ||
``` | ||
|
||
```{r} | ||
head(iris_filtered) | ||
``` | ||
|
||
::: aside | ||
The iris dataset is included in base R. | ||
::: | ||
|
||
## Layout | ||
|
||
This slide shows a two column layout. | ||
|
||
:::: {.columns} | ||
::: {.column width="50%"} | ||
|
||
```{r} | ||
#| label: fig-scatterplot | ||
#| fig-cap: !expr paste0("Scatterplot of ",params$name," species.") | ||
ggplot(iris_filtered,aes(Sepal.Length,Petal.Length,col=Species))+ | ||
geom_point()+ | ||
labs(title=params$name) | ||
``` | ||
|
||
::: | ||
|
||
::: {.column width="50%"} | ||
|
||
```{r} | ||
#| echo: false | ||
#| label: fig-species | ||
#| fig-cap: !expr paste0("Photograph of ",params$name," species.") | ||
imgs <- c( | ||
"setosa" = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Irissetosa1.jpg/220px-Irissetosa1.jpg", | ||
"versicolor" = "https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Blue_Flag%2C_Ottawa.jpg/220px-Blue_Flag%2C_Ottawa.jpg", | ||
"virginica" = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Iris_virginica_2.jpg/220px-Iris_virginica_2.jpg" | ||
) | ||
knitr::include_graphics(imgs[match("versicolor", names(imgs))]) | ||
``` | ||
|
||
::: | ||
:::: | ||
|
||
## Code highlighting | ||
|
||
```{r} | ||
#| echo: true | ||
#| label: fig-scatterplot-size | ||
#| fig-cap: !expr paste0("Scatterplot of ",params$name," species.") | ||
#| code-line-numbers: "2" | ||
ggplot(iris_filtered,aes(Sepal.Length,Petal.Length))+ | ||
geom_point(aes(size=Petal.Width))+ | ||
labs(title=params$name) | ||
``` | ||
|
||
::: {.notes} | ||
The figure is updated to show petal widths. | ||
::: |
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
File renamed without changes.
File renamed without changes.
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