让我们想象以下向量:
test <- c(21.63318,NaN,NaN,24.03223,NaN,NaN,19.18797,NaN,17.71838)
我做了一个简单的总结:
sum.test <- summary(test)
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
17.72 18.82 20.41 20.64 22.23 24.03 5
我想将表导出为乳胶。我尝试过:
print(xtable(as.table(sum.test), type = "latex"), file = "test.tex")
但是我得到:
是否有一种方法可以使它水平(如R中所示)而没有“ x”?
答案 0 :(得分:1)
对不起,include.rownames=FALSE
可以解决问题。
library(xtable)
print(xtable(t(summary(1:8))), type="html", file="xt.html", include.rownames=FALSE)
<!-- html table generated in R 3.5.0 by xtable 1.8-2 package -->
<!-- Tue May 7 17:59:59 2019 -->
<table border=1>
<tr> <th> Min. </th> <th> 1st Qu. </th> <th> Median </th> <th> Mean </th> <th> 3rd Qu. </th> <th> Max. </th> </tr>
<tr> <td align="right"> 1.00 </td> <td align="right"> 2.75 </td> <td align="right"> 4.50 </td> <td align="right"> 4.50 </td> <td align="right"> 6.25 </td> <td align="right"> 8.00 </td> </tr>
</table>