Reputation: 3919
Running latex(rnorm(5),file="")
through the Hmisc
package will display both the contents of the table; for example:
$-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="")
Upvotes: 1
Views: 361
Reputation: 9433
You should see ?Hmisc::latex
for arguments values. You can supress table
and center
environment without rewriting function:
> 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:
> x <- format.df(rnorm(5))
> cat(paste(x, "\\\\", collapse="\n"))
$ 0.184705304659614$ \\
$-1.570758868384333$ \\
$ 0.442248007654160$ \\
$-0.317095653252702$ \\
$ 0.160679032355016$ \\
Upvotes: 1