【发布时间】:2021-03-20 20:32:01
【问题描述】:
我有以下 Rmarkdown 试用版:
---
title: "Test kableExtra"
date: "3/20/2021"
output: pdf_document
classoption: landscape
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(kableExtra)
```
# R Markdown
```{r echo=FALSE}
library(knitr)
library(xtable)
dt <- mtcars[1:5, 1:6]
t1 <- kbl(dt, booktabs = T)
t2 <- kbl(dt, booktabs = T)
t3 <- ggplot(dt,aes(x=mpg,y=cyl)) +
geom_point()
png(file="plot1.png",width=200,height=200)
print(t3)
dev.off() # close the png file
```
Some Text
\begin{table}[!h]
\begin{minipage}{.5\linewidth}
\centering
```{r echo=FALSE}
t1
```
\end{minipage}%
\begin{minipage}{.5\linewidth}
\centering
\includegraphics[width=\textwidth]{plot1.png}
\end{minipage}
\end{table}
当你编织它时它工作正常,但我希望图表和表格在顶部对齐。 有人出主意吗?
如果您有更好的主意将 ggplot 放在 kbl 表旁边,我会全力以赴!
谢谢, 迈克尔
【问题讨论】:
标签: r ggplot2 latex r-markdown