using gsub to modify output of xtable command
Posted
by stevejb
on Stack Overflow
See other posts from Stack Overflow
or by stevejb
Published on 2010-05-17T22:39:45Z
Indexed on
2010/05/17
23:30 UTC
Read the original article
Hit count: 330
Filed under:
r
Hello,
my.mat <- cbind(1:5, rnorm(5), 6:10, rnorm(5))
colnames(my.mat) <- c("Turn", "Draw","Turn", "Draw")
print(xtable(my.mat))
yields
\begin{table}[ht]
\begin{center}
\begin{tabular}{rrrrr}
\hline
& Turn & Draw & Turn & Draw \\
\hline
1 & 1.00 & -0.72 & 6.00 & 0.91 \\
2 & 2.00 & 0.57 & 7.00 & 0.56 \\
3 & 3.00 & 1.08 & 8.00 & 0.55 \\
4 & 4.00 & 0.95 & 9.00 & 0.46 \\
5 & 5.00 & 1.94 & 10.00 & 1.06 \\
\hline
\end{tabular}
\end{center}
\end{table}
I want to filter out the \begin{table} and \end{table} lines. I can do this using gsub, but how to I get the results of print(xtable(... into a variable?
Thanks for the help Stack Overflow R community!
© Stack Overflow or respective owner