Running latex(rnorm(5),file="")
through the Hmisc
package will display both the contents of the table; for example:
通过Hmisc包运行latex(rnorm(5),file =“”)将显示表的内容;例如:
$-0.8036409661674679$\tabularnewline
$ 1.2066652279406598$\tabularnewline
but it will also show the table preamble and ending; for example:
但它也会显示表格前言和结尾;例如:
\end{center}
\end{table}
How do I force the command to only show the formatted contents of the table and not the table preamble/ending?
如何强制命令仅显示表格的格式化内容而不显示表格前导/结尾?
require(Hmisc)
latex(rnorm(5),file="")
1 个解决方案
#1
1
You should see ?Hmisc::latex
for arguments values. You can supress table
and center
environment without rewriting function:
您应该看到?Hmisc :: latex参数值。您可以在不重写功能的情况下抑制表和中心环境:
> 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
function will give you the desired result:
Hmisc :: format_df函数将为您提供所需的结果:
> x <- format.df(rnorm(5))
> cat(paste(x, "\\\\", collapse="\n"))
$ 0.184705304659614$ \\
$-1.570758868384333$ \\
$ 0.442248007654160$ \\
$-0.317095653252702$ \\
$ 0.160679032355016$ \\
#1
1
You should see ?Hmisc::latex
for arguments values. You can supress table
and center
environment without rewriting function:
您应该看到?Hmisc :: latex参数值。您可以在不重写功能的情况下抑制表和中心环境:
> 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
function will give you the desired result:
Hmisc :: format_df函数将为您提供所需的结果:
> x <- format.df(rnorm(5))
> cat(paste(x, "\\\\", collapse="\n"))
$ 0.184705304659614$ \\
$-1.570758868384333$ \\
$ 0.442248007654160$ \\
$-0.317095653252702$ \\
$ 0.160679032355016$ \\