2

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:)

Martin Gal
  • 16,640
  • 5
  • 21
  • 39
meri
  • 29
  • 2
  • You problem is not reproducible with you've given. Can you provide runnable code to look at exact problem? – Miguel Suazo Sep 08 '21 at 14:07
  • Sorry, what do you mean by runnable? Here is the whole Rmd file: --- title: "try" output: html_document --- ```{r} library(tidyverse) mt<-mtcars rpivotTable::rpivotTable(mtcars, rows = "mpg", cols = c("cyl", "hp")) ggplot(mtcars,aes(mpg, cyl))+ geom_bar(stat="identity") ``` – meri Sep 08 '21 at 14:25
  • Runnable mean one can copy paste and start working to help you. With your clarification I was able to provide an answer. – Miguel Suazo Sep 08 '21 at 15:06
  • You could add styling to make it a resizeable table. Using style tags, you would probably want to use something like ``. You can put that anywhere outside of an R chunk. – Kat Apr 25 '22 at 02:53

1 Answers1

0

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>
Miguel Suazo
  • 331
  • 1
  • 4