R/LaTeX 表创建包的建议

发布于 2024-09-04 06:51:01 字数 292 浏览 3 评论 0 原文

我已经使用 xtable 包很长时间了,并期待着用 R 编写我的第一个包......所以我认为,如果我有一些值得实现的“酷”想法,那就是很有可能有人在我之前到达那里...=)

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

聚苯乙烯 我正在考虑构建一个网络应用程序,用户可以在其中定义自己的表格预设/模板、选择样式、统计数据等。不过,这是一个早期的想法... =)

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... =)

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.
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... =)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

つ低調成傷 2024-09-11 06:51:01

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

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

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

  1. 向表格添加任何 LaTeX 特定格式。例如,将数字括在美元符号中以确保负数正确显示。
  2. 通过用与号 (&) 替换单独的列并添加行尾符号“\\”,将行折叠为单个字符值
  3. 添加要在表中显示的任何水平线。我使用 booktabs LaTeX 包。
  4. 使用 write 函数导出生成的字符向量

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

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

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

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

  1. I'll write the table environment, caption, and tabular environment commands directly in my LaTeX document.
  2. I'll export just the body of the table from R using a custom function.

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

  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

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

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.

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

酸甜透明夹心 2024-09-11 06:51:01

超越 xtableHmisc 如 Rob 所列,至少还有

  • apsrtable 从一个或多个模型对象格式化乳胶表
  • p2lh 将 R 导出为 LaTeX 和 HTML
  • RcmdrPlugin.Export,以图形方式将输出导出到 LaTeX 或 HTML
  • reporttools生成描述性统计的 LaTeX 表

这只是基于快速搜索。因此,在尝试将其连接到网络应用程序之前,您可能还需要了解更多内容。祝你好运。

Beyond xtable and Hmisc as listed by Rob, there are also at least

  • apsrtable which formats latex tables from one or more model objects
  • p2lh which exports R to LaTeX and HTML
  • RcmdrPlugin.Export which graphically exports output to LaTeX or HTML
  • reporttools which generates LaTeX tables of descriptive statistics

This was just based on a quick search. So there may be more for you to look at before you try to hook it into a webapp. Good luck.

简单爱 2024-09-11 06:51:01

除了上面提到的包之外,还有 stargazer 包。它适用于许多常用函数和包(lm、glm、svyglm、plm、survival、AER、pscl 等)中的对象以及 zelig 对象。

In addition to the packages mentioned above, there is the stargazer package. It works well with objects from many commonly used functions and packages (lm, glm, svyglm, plm, survival, AER, pscl, and others), as well as with zelig objects.

极度宠爱 2024-09-11 06:51:01

除了 xtable 之外,latex 函数“nofollow noreferrer">Hmisc 包。

Apart from xtable, there's the latex function in the Hmisc package.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文