When the output of the stringr::str_view()
is printed in a slidy presentation it pushes the subsequent text down. I would like to have the text just after the output of the stringr::str_view()
call. I can make the text come right after the stringr::str_view()
output by setting sizingPolicy$knitr$figure <- TRUE
for the object created by the stringr::str_view()
function and also specifying the fig.height
in the chunk option. Is there an easier way to avoid the sebsequent text/code is pushed down in the slidy presentation after running stringr::str_view()
, without I have to manually set fig.height
and sizingPolicy$knitr$figure <- TRUE
each time?
I use R version 4.0.2 on a 64 bit machine with a windows 10 platform.
This code generates the problem:
---
title: 'An example'
output:
slidy_presentation
---
```{r}
library(tidyverse)
library(htmlwidgets)
```
```{r}
x <- c("apple", "banana", "pear")
pattern <- "an"
```
```{r}
str_view(x, pattern)
```
Here some text.
This code solves the problem, but I have to manually set the height of the figure and the sizing policy each time:
---
title: 'An example'
output:
slidy_presentation
---
```{r}
library(tidyverse)
library(htmlwidgets)
```
```{r}
x <- c("apple", "banana", "pear")
pattern <- "an"
```
```{r, fig.height=2}
thewidget <- str_view(x, pattern)
thewidget$sizingPolicy$knitr$figure <- TRUE
thewidget
```
Here some text.