你能合并R中xtable中的单元格吗
我有一些数据(ddply 函数的输出),我想将它们呈现在 xtable 中以供其他地方使用。
calqc_table<-structure(list(RUNID = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), ANALYTEINDEX = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), ID = structure(1:11, .Label = c("Cal A", "Cal B", "Cal C",
"Cal D", "Cal E", "Cal F", "Cal G", "Cal H", "Cal High", "Cal Low",
"Cal Mid"), class = "factor"), mean_conc = c(200.619459644855,
158.264703128903, 102.469121407733, 50.3551544728544, 9.88296440865076,
4.41727762501703, 2.53494715706024, 1.00602831741361, 199.065054555735,
2.48063347296935, 50.1499780776199), sd_conc = c(2.3275711264554,
NA, NA, NA, NA, NA, NA, 0.101636943231162, 0, 0, 0), nrow = c(3,
1, 1, 1, 1, 1, 1, 3, 2, 2, 2)), .Names = c("RUNID", "ANALYTEINDEX",
"ID", "mean_conc", "sd_conc", "nrow"), row.names = c(NA, -11L
), class = "data.frame")
calqc_xtable<-xtable(calqc_table)
print(calqc_xtable,type="html")
这给了我 html 格式的表格。但是,我想将 RUNID 和 ANALYTEINDEX 列的内容垂直合并在一起,其中值相同。有人知道如何通过 xtable (或其他方式吗?)
I've got some data (the output of a ddply function) that I want to present in an xtable for use somewhere else.
calqc_table<-structure(list(RUNID = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), ANALYTEINDEX = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), ID = structure(1:11, .Label = c("Cal A", "Cal B", "Cal C",
"Cal D", "Cal E", "Cal F", "Cal G", "Cal H", "Cal High", "Cal Low",
"Cal Mid"), class = "factor"), mean_conc = c(200.619459644855,
158.264703128903, 102.469121407733, 50.3551544728544, 9.88296440865076,
4.41727762501703, 2.53494715706024, 1.00602831741361, 199.065054555735,
2.48063347296935, 50.1499780776199), sd_conc = c(2.3275711264554,
NA, NA, NA, NA, NA, NA, 0.101636943231162, 0, 0, 0), nrow = c(3,
1, 1, 1, 1, 1, 1, 3, 2, 2, 2)), .Names = c("RUNID", "ANALYTEINDEX",
"ID", "mean_conc", "sd_conc", "nrow"), row.names = c(NA, -11L
), class = "data.frame")
calqc_xtable<-xtable(calqc_table)
print(calqc_xtable,type="html")
which gives me the table in html format. However, I want to Merge together the content of the RUNID and ANALYTEINDEX columns vertically where the values are the same. Anyone know how to do that via xtable (or some other way ?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会“清理”原始数据框,用 NA 替换等于先前值的值。
xtable
会将这些缺失值呈现为空白。如果没有水平边框线,这看起来会很好。现在我们可以将此函数应用于您想要清理的列:
I would "clean up" the original data frame replacing the values that are equal to the previous value by NA.
xtable
will render these missing values as empty spaces. This will look good if you don't have horizontal border lines.Now we can apply this function to the columns that you want cleaned up: