1

运行包会同时显示表格latex(rnorm(5),file="")Hmisc内容;例如:

$-0.8036409661674679$\tabularnewline
$ 1.2066652279406598$\tabularnewline

但它也会显示表格序言和结尾;例如:

\end{center}
\end{table}

如何强制命令显示表格的格式化内容而不显示表格序言/结尾?

require(Hmisc)
latex(rnorm(5),file="")
4

1 回答 1

1

您应该查看?Hmisc::latex参数值。您可以在不重写功能的情况下抑制table和环境:center

> latex(rnorm(5),file="", table.env=FALSE, center="none", multicol=FALSE)
% latex.default(rnorm(5), file = "", table.env = FALSE, center = "none",      multicol = FALSE) 
%
\begin{tabular}{r}
\hline\hline
\tabularnewline
\hline
$ 0.170715837013809$\tabularnewline
$ 1.825384093014966$\tabularnewline
$-0.390987768400953$\tabularnewline
$ 1.429885144215387$\tabularnewline
$-0.505248111252067$\tabularnewline
\hline
\end{tabular}

Hmisc::format_df函数将为您提供所需的结果:

> x <- format.df(rnorm(5))
> cat(paste(x, "\\\\", collapse="\n"))
$ 0.184705304659614$ \\
$-1.570758868384333$ \\
$ 0.442248007654160$ \\
$-0.317095653252702$ \\
$ 0.160679032355016$ \\
于 2013-11-10T03:13:48.950 回答