R/LaTeX表创建包的建议 [英] Suggestion for R/LaTeX table creation package

查看:94
本文介绍了R/LaTeX表创建包的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用xtable包已经很长时间了,期待着用R写我的第一个包...所以我认为,如果我有一些值得考虑的酷"主意,那就太棒了有人在我之前到达那里的机会... =)

I've been using xtable package for a long time, and looking forward to writting my first package in R... so I reckon that if I have some "cool" idea that's worth carying out, there's a great chance that somebody got there before me... =)

我对专门用于LaTeX表创建的功能/包感兴趣(当然是通过R).我碰到了具有latex.table功能的quantreg包.有类似功能/包装的建议吗?

I'm interested in functions/packages specialized for LaTeX table creation (through R, of course). I bumped on quantreg package which has latex.table function. Any suggestion for similar function(s)/package(s)?

P.S. 我正在考虑构建一个Webapp,用户可以在其中定义自己的表格预置/模板,选择样式,统计信息等.不过,这是一个早期的想法,虽然... =)

P.S. I'm thinking about building a webapp in which users can define their own presets/templates of tables, choose style, statistics, etc. It's an early thought, though... =)

推荐答案

我有时将创建LaTeX表的任务分为两部分:

I sometimes divide the task of creating LaTeX tables into two parts:

  1. 我将直接在LaTeX文档中编写表环境,标题和表格环境命令.
  2. 我将使用自定义函数从R中仅导出表主体.

R导出部分涉及几个步骤: 从整个表格的矩阵开始,包括所有标题:

The R export part involves several steps: Starting with a matrix of the whole table including any headings:

  1. 将任何特定于LaTeX的格式添加到表中.例如,将数字括在美元符号中,以确保负数正确显示.
  2. 通过用&符号替换单独的列并添加行尾符号"\\",将行折叠为单个字符值
  3. 添加要在表格中显示的所有水平线.我使用booktabs LaTeX软件包.
  4. 使用write函数导出结果字符向量
  1. Add any LaTeX specific formatting to the table. E.g., enclose digits in dollar symbols to ensure that negative numbers display correctly.
  2. Collapse rows into a single character value by replacing separate columns with the ampersand (&) and adding ends-of-row symbols "\\"
  3. Add any horizontal lines to be displayed in the table. I use the booktabs LaTeX package.
  4. Export the resulting character vector using the write function

然后使用LaTeX中的input命令导入导出的文本文件.我确保文件名与表标签相对应.

The exported text file is then imported using the input command in LaTeX. I ensure that the file name corresponds to the table label.

我在撰写期刊文章时使用了这种方法. 在这些情况下,存在许多不同类型的表格(例如,多页表格,横向表格,需要扩展页边距的表格,需要特殊对齐的表格,我要更改表格标题措辞的表格).在这种情况下,我发现从R导出数据更加容易.通过这种方式,结果是可重复的研究,但是在LaTeX文档中调整表设计的各个方面更容易.而且在期刊文章的上下文中,通常没有太多的表格,而是有特定的格式要求.

I have used this approach in the context of writing journal articles. In these cases, there are a lot of different types of tables (e.g., multi-page tables, landscape tables, tables requiring extended margins, tables requiring particular alignment, tables where I want to change the wording of the table title). In this setting, I've mostly found it easier to just export the data from R. In this way, the result is reproducible research, but it is easier to tweak aspects of table design in the LaTeX document. And in the context of journal articles, there are usually not too many tables and rather specific formatting requirements.

但是,我想如果我要生成大量批处理报告,我会考虑直接从R中导出更多方面.

However, I imagine if I were producing large numbers of batch reports, I'd consider exporting more aspects directly from R.

这篇关于R/LaTeX表创建包的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆