在Knitr或RMarkdown Beamer中并排放置的表格和图形

SGH*_*SGH 8 r beamer knitr r-markdown

我想在RMarkdown/Knitr中创建一个Beamer Presentation幻灯片.在幻灯片中,我希望有一个桌子和一个并排放置的图形,然后是下面的一些文字.我只能在代码中显示我的尝试.我希望在Hmisc表旁边放置密度图.

我没有使用Kable或xtable,因为我可以通过Hmisc更好地控制表格.

另外,如何调整各个幻灯片中的文本特征(字体大小,类型,颜色)?

---
title: "BeamerTest1"
subtitle: Beamer Subtitle
author: "Author"

output:
  beamer_presentation:
    theme: CambridgeUS
    colortheme: "beaver"
    fonttheme: "structurebold"
---

## Slide with Table, Figure and Text

My topic for this slide 

\scalebox{0.35}{
```{r hmisc-table, echo=FALSE, message=FALSE, results='asis'}
library(Hmisc)
latex(head(mtcars), file='', table.env=FALSE, center='none')
```
}


```{r, echo=FALSE, fig.show='hold', fig.height=1, fig.width=2.5}
library(ggplot2)
mt <- ggplot(mtcars, aes(mpg)) + geom_density(alpha=.2, fill="#FF6666") +
  theme(axis.title.x = element_text(size=10),axis.text.x  = element_text(size=8),
        axis.title.y = element_text(size=10),axis.text.y  = element_text(size=8))
mt
```

- Here is some Bullet Text
- And some more
    - Subtext
    - More Subtext
Run Code Online (Sandbox Code Playgroud)

谢谢

Car*_*era 16

正如我已经回答了类似的问题这样,我重申我的回答中,我使用的:::符号,添加代码来创建你可能需要的输出。

您可以使用fenced_divs符号或:::创建列或“两个内容布局”。另请参阅此页面以了解有关该符号的更多信息。

## Slide With Image Left

::: columns

:::: column
left
::::

:::: column
right

```{r your-chunk-name, echo=FALSE, fig.cap="your-caption-name"}
knitr::include_graphics("your/figure/path/to/the-image.pdf")

#The figure will appear on the right side of the slide...
```
::::

:::
Run Code Online (Sandbox Code Playgroud)

由于pandoc 2+支持符号的 是在 中实现的RStudio v1.2+,因此您可能需要先安装RStudio v1.2+。安装很容易(至少在我的情况下);只需下载并安装RStudio v1.2+。在安装方式RStudio上,您电脑上的旧版本将被替换为新版本,无需手动卸载。

下图是一个例子,如果你实现了这个符号。

在此处输入图片说明

生成上面幻灯片的 MWE 代码也在这里:

---
title: "BeamerTest1"
subtitle: Beamer Subtitle
author: "Author"

output:
  beamer_presentation:
  theme: CambridgeUS
  colortheme: "beaver"
  fonttheme: "structurebold"
---

## Slide with Table, Figure and Text

::: columns

:::: column

My topic for this slide 

\scalebox{0.35}{
```{r hmisc-table, echo=FALSE, message=FALSE, results='asis'}
library(Hmisc)
latex(head(mtcars), file='', table.env=FALSE, center='none')
```
}


```{r, echo=FALSE, fig.show='hold', fig.height=1, fig.width=2.5}
library(ggplot2)
mt <- ggplot(mtcars, aes(mpg)) + geom_density(alpha=.2, fill="#FF6666") +
theme(axis.title.x = element_text(size=10),axis.text.x  = element_text(size=8),
axis.title.y = element_text(size=10),axis.text.y  = element_text(size=8))
mt
```

::::

:::: column

- Here is some Bullet Text
- And some more
    - Subtext
    - More Subtext

::::

:::
Run Code Online (Sandbox Code Playgroud)

  • 我不明白为什么这个答案没有得到更多支持。这是最通用的一个,并且真的很巧妙地解决了它。 (2认同)

Jth*_*rpe 0

我认为您想要按照此处fig.align=right所述设置块选项