如何在没有 hlines 的情况下打印 xtable

How to print xtable without hlines

假设我有一个简单的xtable,制作如下:

library(xtable)
x <- as.data.frame(matrix(1:9,3,3))
x <- xtable(x)

我如何打印这个 table 只有列(即“&”),而不是周围的任何东西?我不想明确地使用 hlines。

使用:

print(x,
only.contents=T)

returns\hline前后table。我也很高兴有一个解决方法,尽管我希望可以在 xtable 中以某种方式按预期进行设置。感谢您的任何提示。

您可以将hline.after设置为NULL;见下文:

library(xtable)
x <- as.data.frame(matrix(1:9,3,3))
print(xtable(x),
      only.contents=T)

#> % latex table generated in R 3.6.0 by xtable 1.8-4 package
#> % Wed Sep 18 11:54:58 2019
#>  & V1 & V2 & V3 \ 
#>   \hline
#> 1 &   1 &   4 &   7 \ 
#>   2 &   2 &   5 &   8 \ 
#>   3 &   3 &   6 &   9 \ 
#>    \hline
print(xtable(x),
      hline.after = NULL,
      only.contents=T)

#> % latex table generated in R 3.6.0 by xtable 1.8-4 package
#> % Wed Sep 18 11:54:58 2019
#>  & V1 & V2 & V3 \ 
#>  1 &   1 &   4 &   7 \ 
#>   2 &   2 &   5 &   8 \ 
#>   3 &   3 &   6 &   9 \ 
#> 

您可以在 ?print.xtable 阅读更多内容。