我正在为工作中的一些新 R 用户整理一个 R Markdown HTML 页面,向他们进行介绍并引导他们完成一些简单的演示。
在炫耀诸如此类的东西时head
and tail
,它最终看起来又乱又长,因为它一个接一个地打印出每个输出。我希望它们与我的 .Rmd 的其他部分一样分成两列。
在我的研究中,我遇到了这个question https://stackoverflow.com/questions/19237190/2-column-report-in-r-markdown-render-html-aside-data-frame。有一些关于我不理解的 HTML 代码的解决方法的讨论。
我确实尝试过包括:
<div class="columns-2">
</div>
来自官方rmarkdown
文档,但没有任何效果。
当我准备放弃时,@Molx 对 Stack Overflow 问题的评论说你可以使用分隔列***
,但没有给出任何进一步的解释。我尝试了几种方法:***
在 R 代码块的中间,我将 R 代码块分开并放置***
两者之间。当我执行后者时,***
只是变成了一条水平线,对柱子没有任何作用。
我希望尽可能避免使用表格和 CSS。
rmarkdown 文件:
#### Put in your css file or directly in rmarkdown
<style>
.col2 {
columns: 2 200px; /* number of columns and width in pixels*/
-webkit-columns: 2 200px; /* chrome, safari */
-moz-columns: 2 200px; /* firefox */
}
.col3 {
columns: 3 100px;
-webkit-columns: 3 100px;
-moz-columns: 3 100px;
}
</style>
#### This section will have three columns
<div class="col3">
**1** one
**2** two
**3** three
**4** four
**5** five
**6** six
**7** seven
**8** eight
**9** nine
</div>
#### This section will have two columns
<div class="col2">
```{r}
head(mtcars)
tail(mtcars)
```
</div>
给我这个
Edit
为了更精确地使用列元素,您可以对每组元素使用 div:
Rmd file
<style>
.column-left{
float: left;
width: 33%;
text-align: left;
}
.column-center{
display: inline-block;
width: 33%;
text-align: center;
}
.column-right{
float: right;
width: 33%;
text-align: right;
}
</style>
#### This section will have three columns
<div class="column-left">
**1** one
**2** two
</div>
<div class="column-center">
**3** three
**4** four
**5** five
**6** six
</div>
<div class="column-right">
**7** seven
**8** eight
**9** nine
</div>
Gives me
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)