我正在重新提出这个问题: How to wrap text around plots in R Markdown?:
'目前R中R Markdown的默认值是让一行文字与情节一致,但这看起来很尴尬,我想通过让文字环绕绘图来节省空间(图左对齐,文字包装在右边)。'
答案 0 :(得分:11)
您可以使用CSS样式来定位您想要的元素。然而,可能存在一些困难,它确实需要一些调整。这是一个简单的例子:
---
title: "Untitled"
author: "Ian Wesley"
date: "April 21, 2017"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
<div style= "float:right;position: relative; top: -80px;">
```{r pressure, echo=FALSE}
plot(pressure)
```
</div>
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
收率:
答案 1 :(得分:2)
现在似乎有一种更简单的方法,即将两个参数添加到r块中:
out.width= "65%", out.extra='style="float:right; padding:10px"'
这会将绘图比例缩放为页面宽度的65%,并使文本以10px的距离浮动在左侧。