将 xtable 输出拆分为子表
有一个关于在有多列时将 xtable 与 Sweave 一起使用的问题。我正在处理的表格大约有 25 列和 5 行。确切的列数未知,因为它是动态的。
当我跑步时说,
table1 <- 表 (df$someField)
我得到一个基本上超过页面长度的表。
ColA ColB ColC
---------------------------
RowA 1 2 3 ......
RowB 3 4 6 ......
如果对此执行 xtable,并通过 Sweave 运行它,
xtable(table1, caption="some table")
它就会溢出。
我正在寻找类似的东西,
ColA ColB ColC
---------------------------
RowA 1 2 3
RowB 3 4 6
ColD ColE ColF
---------------------------
RowA 11 9 34
RowB 36 8 65
带有 \hline 等标记。基本上,将 xtable 分成多个部分,例如每个“子表”5 列。
我也在批处理作业中运行它,因此我无法对单个文件进行更改,无论它必须能够通过在 Rnw 文件上运行 Sweave 生成什么解决方案。
预先感谢,
问候,
- 拉杰。
Have a question on using xtable with Sweave when there are multiple columns. A table I am working on has about 25 columns and 5 rows. The exact number of columns is not known as that is dynamic.
When I run say,
table1 <- table (df$someField)
I get a table that essentially exceeds the page length.
ColA ColB ColC
---------------------------
RowA 1 2 3 ......
RowB 3 4 6 ......
If a do a xtable on this, and run it through Sweave,
xtable(table1, caption="some table")
it overflows.
What I am looking for is something like,
ColA ColB ColC
---------------------------
RowA 1 2 3
RowB 3 4 6
ColD ColE ColF
---------------------------
RowA 11 9 34
RowB 36 8 65
with the \hline etc markups. Basically, split the xtable into parts by say 5 columns per "sub-table".
I am also running this in a batch job, so I won't be able to make changes to individual files, whatever the solution it has to be able to be generated by running Sweave on the Rnw file.
Thanks in advance,
Regards,
- Raj.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是来自
taRifx
包中的?latex.table.by
的示例。您可以在 LaTeX 中使用longtable
编写类似的内容,并使用latex.table.by
代码作为原型。无论如何,LaTeX 中的
longtable
包是关键。编辑:看来您的列太多,而不是行太多。在这种情况下,首先尝试仅美化该页面。
在标题中:
在桌子周围:
或者仅使用
sidewaystable
。如果您的表格太宽而无法容纳一页,请尝试
supertabular
包,从描述来看,它可能会根据宽度处理跨多个页面的情况(但我从未使用过它,所以可以不确定)。Here's an example of this from
?latex.table.by
in thetaRifx
package. You can brew something similar usinglongtable
in LaTeX and use thelatex.table.by
code as a prototype.Regardless, the
longtable
package in LaTeX is the key.Edit: It appears you have too many columns not too many rows. In that case, first try landscaping just that page.
In the header:
Around your table:
Or just use
sidewaystable
.If your table is too wide to fit in one page, try the
supertabular
package, which from the description sounds like it might handle breaking over multiple pages based on width (but I've never used it so can't be sure).