gpt4 book ai didi

r - rmarkdown 表的单个单元格中的多行

转载 作者:行者123 更新时间:2023-12-04 10:40:04 24 4
gpt4 key购买 nike

我想使用 RMarkdown 创建一个在单个单元格中包含多行的表格。此页面提到多行和网格表格单元格 ( http://rmarkdown.rstudio.com/authoring_pandoc_markdown.html )。但似乎反斜杠不起作用。

A backslash followed by a newline is also a hard line break. 
Note: in multiline and grid table cells, this is the only way
to create a hard line break, since trailing spaces in the cells are ignored.

这是我的示例 Rmd 文件。

---
title: "Test"
author: "test"
date: "Tuesday, November 25, 2014"
output: html_document
---
Line 1 \ Line2 | Line 1 \ Line2
------------- | -------------
Line 1 \ Line2 | Line 1 \ Line2

这有可能实现吗?感谢您的任何建议。

这是我的 session 信息

> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] digest_0.6.4 htmltools_0.2.6 rmarkdown_0.3.11 tools_3.1.1

最佳答案

这是绝对可行的,参见例如 pander.CrossTable 使用这种方法:

> pander::pander(descr::CrossTable(mtcars$am, mtcars$gear))

----------------------------------------------------------------
 \ mtcars$gear\  \  \  \
mtcars$am 3 4 5 Total
------------ -------------- ----------- ------------ -----------
**0**\  \  \  \  \
N\ 15\ 4\ 0\ 19\
Chi-square\ 4.1694\ 1.3706\ 2.9688\ \
Row(%)\ 78.9474%\ 21.0526%\ 0.0000%\ 59.3750%\
Column(%)\ 100.0000%\ 33.3333%\ 0.0000%\ \
Total(%) 46.875% 12.500% 0.000%

**1**\  \  \  \  \
N\ 0\ 8\ 5\ 13\
Chi-square\ 6.0938\ 2.0032\ 4.3389\ \
Row(%)\ 0.0000%\ 61.5385%\ 38.4615%\ 40.6250%\
Column(%)\ 0.0000%\ 66.6667%\ 100.0000%\ \
Total(%) 0.000% 25.000% 15.625%

Total\ 15\ 12\ 5\ 32\
46.875% 37.5% 15.625%
----------------------------------------------------------------

关于r - rmarkdown 表的单个单元格中的多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27120954/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com