R 你能在一个xtable中合并单元格吗

R 你能在一个xtable中合并单元格吗,r,xtable,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

我有一些数据(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")
calqc_table我将“清理”原始数据框,用NA替换等于先前值的值
xtable
将这些缺少的值呈现为空白。如果没有水平边界线,这看起来会很好

cleanf <- function(x){ 
   oldx <- c(FALSE, x[-1]==x[-length(x)])  # is the value equal to the previous?
   res <- x
   res[oldx] <- NA        
   res}
cleanf是的,这几乎是完美的(使用向量化函数的额外荣誉,我肯定会打破下一个循环…)
clean.cols <- c( "RUNID", "ANALYTEINDEX")
calqc_table[clean.cols] <- lapply(calqc_table[clean.cols], cleanf)