How can I avoid rpivotTable overlapping rest of HTML report?

155 Views Asked by At

I am trying to include an rpivotTable in my HTML report but it keeps overlapping the graph I have below.

This is an example code so that you can see that when you render Rmd to HTML it will overlap whatever is below.

library(tidyverse)
mt <- mtcars

rpivotTable::rpivotTable(mtcars, rows = mpg, columns = c(cyl, hp))

ggplot(mtcars, aes(mpg, cyl)) +
  geom_bar(stat="identity")

I have tried using the height and width arguments with no success.

As the pivot table is interactive and can change in size, I would like the graph below to automatically make space to fit the pivot table.

Thanks for your help:)

1

There are 1 best solutions below

1
Miguel Suazo On

Include both objects in different divs in markdown. You can format height there:

---
title: "Untitled"
output: html_document
---

<div style="height: 1500px;" markdown="1">
```{r a, echo=FALSE}

library(tidyverse)
mt<-mtcars  

rpivotTable::rpivotTable(mtcars, rows = "mpg", cols = c("cyl", "hp"))  

```


</div>
<div style="height: 100%;" markdown="2">
```{r b, echo=FALSE}



ggplot(mtcars,aes(mpg, cyl))+   geom_bar(stat="identity")

```
</div>