简体   繁体   English

使用 R、Sweave 和 LaTeX 创建出版质量表的一般指南

[英]General guide for creating publication quality tables using R, Sweave, and LaTeX

There are a range of tools available for creating publication quality tables using R, Sweave, and LaTeX.有一系列工具可用于使用 R、Sweave 和 LaTeX 创建出版质量表。 In particular, there are helper functions like latex in the Hmisc package, and xtable in the xtable package.特别地,有喜欢的辅助功能latexHmisc包,并xtablextable包。 I've also often written my own code so that I could have complete control over table formatting (eg, see this example ).我也经常编写自己的代码,以便我可以完全控制表格格式(例如,请参阅此示例)。

However, when preparing publication quality tables a range of issues often arise:然而,在准备出版质量表时,经常会出现一系列问题:

  • how and when to apply numeric formatting如何以及何时应用数字格式
  • how to precisely control alignment of columns and cells如何精确控制列和单元格的对齐方式
  • how to precisely control cell borders如何精确控制单元格边框
  • how to convert variable labels to variable names如何将变量标签转换为变量名称
  • and so on等等

Beyond the high level issues of specifying the desired table format, there are issues of implementation.除了指定所需表格格式的高级问题之外,还有实现问题。

  • When should a helper function such as xtable be used?什么时候应该使用像xtable这样的辅助函数?
  • Which helper function should be used in a given situation?在给定的情况下应该使用哪个辅助函数?
  • How can the default output of helper functions be customised to particular requirements?辅助函数的默认输出如何根据特定要求进行定制?

Question问题

It seems to me that the above issues are deserving of a detailed textbook-style introduction.在我看来,上述问题值得用教科书式的详细介绍。

Are there any online or offline resources that provide a detailed overview of how to produce publication quality tables using R, Sweave, and LaTeX, and that address the issues discussed above?是否有任何在线或离线资源可以详细概述如何使用 R、Sweave 和 LaTeX 生成出版物质量表,并解决上述问题?

Just to tie this up with a nice little bow at the time of current writing, the best existant tutorials on publication-quality tables and usage scenarios appear to be an amalgamation of these documents:在撰写本文时,为了将其与一个漂亮的小蝴蝶结联系起来,关于出版质量表和使用场景的最佳现有教程似乎是这些文档的合并:

Going beyond the scope of what currently exists, you may want to ask the author of The Joy of Sweave for a document on publication-quality tables specifically.超出当前存在的范围,您可能需要向The Joy of Sweave的作者索取一份专门关于出版质量表的文档。 It seems like he's gone above and beyond this problem in his research.在他的研究中,他似乎已经超越了这个问题。 In addition to the questions you've raised, this space specifically could use a style guide that, flatly, does not currently exist.除了您提出的问题之外,这个空间特别可以使用目前尚不存在的风格指南。

And, as mentioned in the question errata, this is a perfect example of a question for https://tex.stackexchange.com/ .而且,正如问题勘误中所述,这是https://tex.stackexchange.com/问题的完美示例。 I encourage you to continue to ask specific questions there when you run into any difficulties in your current projects.当您在当前项目中遇到任何困难时,我鼓励您继续在那里提出具体问题

The package stargazer can create publication-quality - incl.stargazer可以创建出版物质量 - 包括。 using templates designed to resemble existing academic journals - from commonly used R statistical functions and packages (lm, glm, plm, svyglm, survival, pscl, AER, and others).使用旨在类似于现有学术期刊的模板 - 来自常用的 R 统计函数和包(lm、glm、plm、svyglm、survival、pscl、AER 等)。 Also good for creating summary statistics tables, and can directly output data frame content as well.也适用于创建汇总统计表,也可以直接输出数据框内容。

There is a tabular function in the tables package which addresses formatting, alignment and label operations. tables包中有一个tabular函数,用于处理格式、对齐和标签操作。 The package has a vignette which is a good starting point.包裹有一个小插图,这是一个很好的起点。

xtable has worked fine for me so far. xtable对我来说效果很好。 In combination with siunitx , and when necessary, longtable , it can produce pretty effective tables, in my opinion.在我看来,结合siunitx以及必要时的longtable ,它可以生成非常有效的表。 With packages like booktabs and caption , the aesthetics can be pleasing too.使用booktabscaption等包,美学也可以令人愉悦。

I am not sure this level of detail was asked for by the OP, but for what it's worth, the basic implementation could be something along these lines: https://tex.stackexchange.com/questions/41067/caption-for-longtable-in-sweave/41183#41183 (my own answer to another question).我不确定 OP 是否要求这种级别的详细信息,但对于它的价值,基本实现可能是以下几行: https : //tex.stackexchange.com/questions/41067/caption-for-longtable -in-sweave/41183#41183 (我自己对另一个问题的回答)。

I highly recommend ConTeXt which makes use of the TABLE package.我强烈推荐使用 TABLE 包的 ConTeXt。 There is a Table overview in contextgarden and an exhaustive manual . contextgarden 中有一个表格概述和详尽的手册

Thank you!谢谢! this post is well-appreciated!这个帖子很受欢迎! That is very informative and those are one of the things they use.这是非常有用的,这些是他们使用的东西之一。 As someone who is not familiar with the term, I am so grateful for this kind of post.作为一个不熟悉这个术语的人,我非常感谢这种帖子。 This is truly the best reference for when I need it.这确实是我需要时的最佳参考。 Also, Do you know any site that provides detailed or more detailed discussion regarding this?另外,您知道任何提供有关此问题的详细或更详细讨论的站点吗? I might need it!我可能需要它!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM