Skip to content

Commit

Permalink
Added parameterized report and revealjs
Browse files Browse the repository at this point in the history
  • Loading branch information
royfrancis committed May 8, 2023
1 parent 35402b2 commit 983249e
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 17 deletions.
13 changes: 0 additions & 13 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,5 @@ project:
type: website
output-dir: docs

format:
html:
theme: materia
fig-align: left
title-block-banner: true
author: "Roy Francis"
date: last-modified
date-format: "DD-MMM-YYYY"

knitr:
opts_chunk:
results: hold

filters:
- assets/custom.lua
8 changes: 8 additions & 0 deletions reports/ojs/index.qmd → documents/ojs/index.qmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
---
title: ObservableJS in Quarto
description: "Integrating OJS and R in Quarto"
format:
html:
theme: materia
fig-align: left
title-block-banner: true
author: "Roy Francis"
date: last-modified
date-format: "DD-MMM-YYYY"
---

## Passing data
Expand Down
64 changes: 64 additions & 0 deletions documents/para/index.qmd
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))])
```
66 changes: 66 additions & 0 deletions documents/para/pdf.qmd
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))])
```
88 changes: 88 additions & 0 deletions documents/revealjs/index.qmd
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.
:::
5 changes: 5 additions & 0 deletions reports/webr/index.qmd → documents/webr/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ number-sections: true
format:
html:
theme: materia
fig-align: left
title-block-banner: true
author: "Roy Francis"
date: last-modified
date-format: "DD-MMM-YYYY"
engine: knitr
filters:
- webr
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions index.qmd
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
---
title: "Quarto experiments"
description: "Testing quarto documents"
date: ""
author: ""
---

### [OJS and R in Quarto](reports/ojs/index.qmd)
### [WebR in Quarto using Quarto webr extension](reports/webr/index.qmd)
### [Parameterized report](documents/para/index.qmd)
### [OJS and R in Quarto](documents/ojs/index.qmd)
### [WebR in Quarto using Quarto webr extension](documents/webr/index.qmd)

<br>

Expand Down

0 comments on commit 983249e

Please sign in to comment.