Pay attention to @James answer for the correct answer (I didn’t even check that, as I believed, @mmmasterluke really read the docs).
Alternatively, you can use toLatex
from the memisc
package:
library(memisc) x <- c(2.222, 3.333, 6.6666) df <- data.frame(x) toLatex(df, digits=4)
gives you
\begin{tabular}{D{.}{.}{4}} \toprule \multicolumn{1}{c}{x} \\ \midrule 2.2220 \\ 3.3330 \\ 6.6666 \\ \bottomrule \end{tabular}
And it has many other parameters that you can use to configure latex output.
source share