【问题标题】:How can I avoid rpivotTable overlapping rest of HTML report?如何避免 rpivotTable 与 HTML 报告的其余部分重叠?
【发布时间】:2021-11-05 07:29:33
【问题描述】:

我试图在我的 HTML 报告中包含一个 rpivotTable,但它一直与下面的图表重叠。

这是一个示例代码,因此您可以看到,当您将 Rmd 渲染为 HTML 时,它将与下面的内容重叠。

library(tidyverse)
mt <- mtcars

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

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

我尝试使用高度和宽度参数,但没有成功。

由于数据透视表是交互式的并且可以改变大小,我希望下图能够自动腾出空间以适应数据透视表。

感谢您的帮助:)

【问题讨论】:

  • 您给出的问题无法重现。你能提供可运行的代码来查看确切的问题吗?
  • 对不起,您所说的可运行是什么意思?这是整个 Rmd 文件: --- 标题:“try” 输出:html_document --- {r} library(tidyverse) mt&lt;-mtcars rpivotTable::rpivotTable(mtcars, rows = "mpg", cols = c("cyl", "hp")) ggplot(mtcars,aes(mpg, cyl))+ geom_bar(stat="identity")
  • Runnable 意味着可以复制粘贴并开始为您提供帮助。通过您的澄清,我能够提供答案。

标签: html r ggplot2 r-markdown rpivottable


【解决方案1】:

在 markdown 的不同 div 中包含两个对象。您可以在那里格式化高度:

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

【讨论】:

  • 谢谢。如果我还包括
    它可以让我适应表格并滚动溢出。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多