如何从 R 生成报告质量表?
如果我有以下称为结果的数据框,
> result
Name CV LCB UCB
1 within 2.768443 1.869964 5.303702
2 between 4.733483 2.123816 18.551051
3 total 5.483625 3.590745 18.772389
> dput(result,"")
structure(list(Name = structure(c("within", "between", "total"
), .rk.invalid.fields = list(), .Label = character(0)), CV = c(2.768443,
4.733483, 5.483625), LCB = c(1.869964, 2.123816, 3.590745), UCB = c(5.303702,
18.551051, 18.772389)), .Names = c("Name", "CV", "LCB", "UCB"
), row.names = c(NA, 3L), class = "data.frame")
那么很好地呈现此数据的最佳方式是什么?理想情况下,我想要一个可以粘贴到报告中的图像文件,或者可能是一个代表表格的 HTML 文件?
设置有效数字的额外积分。
If I have the following dataframe called result
> result
Name CV LCB UCB
1 within 2.768443 1.869964 5.303702
2 between 4.733483 2.123816 18.551051
3 total 5.483625 3.590745 18.772389
> dput(result,"")
structure(list(Name = structure(c("within", "between", "total"
), .rk.invalid.fields = list(), .Label = character(0)), CV = c(2.768443,
4.733483, 5.483625), LCB = c(1.869964, 2.123816, 3.590745), UCB = c(5.303702,
18.551051, 18.772389)), .Names = c("Name", "CV", "LCB", "UCB"
), row.names = c(NA, 3L), class = "data.frame")
What is the best way to present this data nicely? Ideally I'd like an image file that can be pasted into a report, or possibly an HTML file to represent the table?
Extra points for setting number of significant figures.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我会使用xtable。我通常将它与 Sweave 一起使用。
如果你想在 Sweave 文档中使用它,你可以像这样使用它:
I would use xtable. I usually use it with Sweave.
If you want to use it in a Sweave document, you would use it like so:
对于表格方面, xtable 包是这样的它可以生成 LaTeX 输出(您可以通过 Sweave 将其用于专业报告)以及 html。
如果您将 Sweave 中的内容与精美的图表结合起来(请参阅有关 ggplot 示例的其他问题),那么您就快完成了。
For the table aspect, the xtable package comes to mind as it can produce LaTeX output (which you can use via Sweave for professional reports) as well as html.
If you combine that in Sweave with fancy graphs (see other questions for ggplot examples) you are almost there.
要设置有效数字,最简单的方法(请注意,对于此示例数据)是将 Name 移动到 rowname 并对整个内容进行舍入。
这不是一个非常强大的解决方案 - 我认为非唯一的名称值会破坏它,就像其他非数字列一样。但对于生成像您的示例这样的表格,它就可以了。
To set the significant figures, the easiest thing to do (for this sample data, mind you) would be to move Name to rownames and round the whole thing.
This is not a terribly robust solution - non-unique Name values would break it, I think, as would other non-numeric columns. But for producing a table like your example, it does the trick.