Using bookdown commands in ioslides presentation - r

Using bookdown commands in an R markdown presentation with output format "beamer" works fine (see also this SO-post).
In the YAML header, one simply has to change from
output:
beamer_presentation: default
to
output:
bookdown::pdf_book:
base_format: rmarkdown::beamer_presentation
However, how to use bookdown commands in an R markdown presentation with output format "ioslides"
MWE:
---
title: "ioslides_presentation with bookdown commands"
output:
ioslides_presentation: default
# Not working:
# bookdown::pdf_book:
# base_format: rmarkdown::ioslides_presentation
---
# Set of slides
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## Slide with bookdown cross references
- Figure: \#ref(fig:plot)
- Table: \#ref(tab:table)
- Slide without ref: \#ref(some-slide)
- Slide with ref: \#ref(slide-with-ref)
## Slide with Plot
```{r plot, fig.cap='Plot caption'}
plot(pressure)
```
## Slide with Table
```{r table}
knitr::kable(head(mtcars[, 1:3]),
caption = "Table caption")
```
## Some Slide
Some text
## Another Slide {#slide-with-ref}
Some more text

Related

How to show figure captions in reveal.js slides made using R Markdown

I am producing reveal.js slides using R Markdown and bookdown and the output slides do not show any figure captions, as shown in a figure below. What am I missing?
MWE
---
author: CLRR
date: |
| Last Update: `r format(Sys.time(), '%Y/%m/%d')`)
output:
#revealjs::revealjs_presentation:
bookdown::html_document2:
base_format: "function(...) revealjs::revealjs_presentation(...)"
self_contained: false
reveal_plugins: ["notes", "search"]
transition: slide
pandoc_args:
- --wrap=preserve
---
## A slide with a figure
Figure \#ref(fig:awesome-figure) shows an awesome figure.
(ref:awesome-figure) The awesome figure
![(#fig:awesome-figure) (ref:awesome-figure) hoge](https://i.imgur.com/DZnMWrI.png)
## Ts
```{r,echo = FALSE, warning = FALSE,message=FALSE, fig.cap= "Cars' cty"}
library(ggplot2)
data(mtcars)
ggplot(mpg, aes(cty)) + geom_bar()
```

Layout objects on R Slidy using flexdashboard or HTML... or some other method

I'm really looking for a guide on the layout of Slidy slides. Specifically, I'm trying to arrange plots and tables on a slide. I guess the flexdashboard example would look something like below:
---
title: "Min_Example"
author: "Brian Balzar"
date: "3/23/2022"
output: slidy_presentation
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
# Example Slide
## Row
### Equation
$$
a^2 + b^2 = c^2
$$
## Row
## Column 1
### Summary
```{r cars, echo = TRUE}
summary(cars)
```
## Column 2
### Chart
```{r plot}
plot(cars)
```
### Row
```{r table}
knitr::kable(cars)
```
I'm open to doing this in HTML, just need to know how to do it!

Linking two code blocks together so that their output appears under the same category in the markdown

I've got a couple of charts that show two related data sets. I would like to have them appear in the same 'category' on the markdown, but under two separate 'subtitles' on the table of contents.
My YAML follows this pattern (though I have also used "toc:true" and "toc_float: true" previously):
---
title: "Update"
author: "Me"
date: "`r Sys.Date()`"
output:
rmdformats::readthedown:
fig_width: 12
fig_height: 5
---
The code I use to produce the charts in the markdown follows this format:
# Time-series
## Nominal
```{r chart1,echo=FALSE, cache=FALSE, warning=FALSE, message=FALSE, fig.height=25,fig.width=10}
Chart1
```
## Real
```{r chart2,echo=FALSE, cache=FALSE, warning=FALSE, message=FALSE, fig.height=25,fig.width=10}
Chart2
```
The 'category title' (Time-series) and 'subtitle' (Nominal) work as intended, and appear linked in the table of contents when the markdown is produced. The second 'subtitle' (Real) appears unlinked, and while it seems to recognise that 'Real' is intended to be a subtitle in RStudio, when the markdown html is produced it neither recognizes as a subtitle nor does it link it to the 'category title' above. Does anyone how to achieve this?
you are missing a blank line between chunk1 and ## Real
---
title: "Untitled"
author: "domingo"
date: "11 2 2022"
output:
html_document:
toc: TRUE
toc_float: TRUE
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Time-series
## Nominal
```{r chart1,echo=FALSE, cache=FALSE, warning=FALSE, message=FALSE, fig.height=25,fig.width=10}
plot(mtcars)
```
## Real
```{r chart2,echo=FALSE, cache=FALSE, warning=FALSE, message=FALSE, fig.height=25,fig.width=10}
plot(mtcars)
```

Plot a hierarchy tabs in R Markdown

I have been trying to plot a hierarchy tabs in R markdown but somehow when I knit the document it does not show the tabs. I was expecting: Score should have Plots and Plots123 as sub tab and Score1 should be aligned with Score tab. But my output does not show any tabs.
PS: (I have purposely written `` while defining a chunk because Stack overflow interprets '```' as code)
## Score {.tabset}
### Plots
``
{r pressure, echo=FALSE}
plot(pressure)
``
### Plots123
``{r pressure_1, echo=FALSE}
plot(pressure)
``
## Scores1 {.tabset}
``{r pressure_2, echo=FALSE}
plot(pressure)
``
Here's my version - this seems to work. Try this out exactly and let me know.
For rmarkdown, all sub-headers of the header with the .tabset attribute appear within tabs rather than as standalone sections. Also, trying additional spacing between headers.
---
title: "Test"
author: "Test"
date: "2/29/2020"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Score {.tabset}
### Plots
```{r pressure, echo=FALSE}
plot(pressure)
```
### Plots123
```{r pressure_1, echo=FALSE}
plot(pressure)
```
## Scores1 {.tabset}
```{r pressure_2, echo=FALSE}
plot(pressure)
```

How do I produce a plot in landscape [rotated by 90 degrees] orientation in knitr?

The following knitr code give me the plot below -- how do I plot it in a landscape orientation?
```{r}
rm(list=ls())
library(tree)
set.seed(1111)
x1<-runif(100)
x2<-rnorm(100,mean=.3)
x3<-runif(100)
d1<-x1>0.5
d2<-x2>0.7
d3<-x3<0.2
y<-ifelse(d1,1,ifelse(d2,2,ifelse(d3,3,4)))
df<-data.frame(x1,x2,x3,y)
tr<-tree(y~.,data=df)
plot(tr)
text(tr)
```
If your want a pdf/LaTeX output it is quite easy with out.extra='angle=90' chunk argument :
---
title: "Rotation test"
output: pdf_document
---
```{r, out.extra='angle=90'}
rm(list=ls())
library(tree)
set.seed(1111)
x1<-runif(100)
x2<-rnorm(100,mean=.3)
x3<-runif(100)
d1<-x1>0.5
d2<-x2>0.7
d3<-x3<0.2
y<-ifelse(d1,1,ifelse(d2,2,ifelse(d3,3,4)))
df<-data.frame(x1,x2,x3,y)
tr<-tree(y~.,data=df)
plot(tr)
text(tr)
```
In some circumnstances it is better to keep the graph as it but to rotate just one page in landscape format within you document.
You need pdflscape LaTeX package for this (included for example in the texlive-latex-base package in Ubuntu as "oberdiek").
In the following example the graph is extended to occupy a full A4 page in landscape format. NB : you must specify fig.align='center' to make it work.
---
title: "Rotation test"
output: pdf_document
header-includes:
- \usepackage{pdflscape}
---
```{r}
rm(list=ls())
library(tree)
set.seed(1111)
x1<-runif(100)
x2<-rnorm(100,mean=.3)
x3<-runif(100)
d1<-x1>0.5
d2<-x2>0.7
d3<-x3<0.2
y<-ifelse(d1,1,ifelse(d2,2,ifelse(d3,3,4)))
df<-data.frame(x1,x2,x3,y)
tr<-tree(y~.,data=df)
```
\newpage
\begin{landscape}
```{r fig.align='center', fig.width = 27/2.54, fig.height = 19/2.54}
plot(tr)
text(tr)
```
\end{landscape}
```{r}
summary(tr)
```

Resources