I want to export my outputs from R to latex using xtable. In addition, I want each of the tables to have an estimate and its standard error. How do I get the elements of a particular row of the matrix in box brackets in R?
The expected output by applying function xtable to the resulting data frame should be as follows:
\begin{tabular}{lcccc}
\hline
& Hi & MV & Zi & Pi \\
\hline
Mean & 0.57 & 0.50 & 0.54 & 0.42 \\
& [0.01] & [0.01] & [0.01] & [0.05] \\
Median & 0.57 & 0.50 & 0.54 & 0.42 \\
& [0.01] & [0.01] & [0.01] & [0.05] \\
MSE & 0.08 & 0.02 & 0.05 & 0.16 \\
& [0.01] & [0.00] & [0.01] &[ 0.04] \\
\hline
\end{tabular}
Thank you.
you could try this,
Note: I would probably define a LaTeX macro, e.g.
\newcommand{\wrap}[1]{\ensuremath{\left[#1\right]}}
, withx[i,j] <- sprintf("\\wrap{%s}", x[i,j])
in the R code.