Consider this simple example
data <- data.frame(string = c('one','two'))
data
# string
# 1 one
# 2 two
I want to write this data.frame
to a tex
file.
I can use xtable
xtable(data)
with TeX output
% latex table generated in R 3.3.1 by xtable 1.8-2 package
% Wed Jan 04 11:39:40 2017
\begin{table}[ht]
\centering
\begin{tabular}{rl}
\hline
& string \\
\hline
1 & one \\
2 & two \\
\hline
\end{tabular}
\end{table}
Problem is: I need to get rid of
\begin{table}[ht]
\centering
\begin{tabular}{rl}
\hline
and
\end{tabular}
\end{table}
so that I only have
& string \\
\hline
1 & one \\
2 & two \\
\hline
in my tex
file.
Any ideas how to do that? Thanks!
That's exactly the point of the
only.contents
argument toprint.xtable
:With TeX output
(it also has an argument
comment
if you'd like to suppress the TeX comment)