How do I disable automatic rounding in this case?
> x <- c(2.222, 3.333, 6.6666)
> df <- data.frame(x)
> df
x
1 2.2220
2 3.3330
3 6.6666
> xtable(df)
Results in
% latex table generated in R 2.11.1 by xtable 1.5-6 package
% Tue Oct 25 12:13:08 2011
\begin{table}[ht]
\begin{center}
\begin{tabular}{rr}
\hline
& x \\
\hline
1 & 2.22 \\
2 & 3.33 \\
3 & 6.67 \\
\hline
\end{tabular}
\end{center}
\end{table}
I can't find any option in the docs of xtable to turn it off.
How about digits
?
xtable(df,digits=4)
% latex table generated in R 2.12.2 by xtable 1.5-6 package
% Tue Oct 25 11:39:25 2011
\begin{table}[ht]
\begin{center}
\begin{tabular}{rr}
\hline
& x \\
\hline
1 & 2.2220 \\
2 & 3.3330 \\
3 & 6.6666 \\
\hline
\end{tabular}
\end{center}
\end{table}
You can do it by transforming all columns into string, although it could generate some warning message:
> xtable(df, display=rep("s",ncol(df)+1))
% latex table generated in R 3.3.3 by xtable 1.8-2 package
% Tue Oct 24 12:43:58 2017
\begin{table}[ht]
\centering
\begin{tabular}{rr}
\hline
& x \\
\hline
1 & 2.222 \\
2 & 3.333 \\
3 & 6.6666 \\
\hline
\end{tabular}
\end{table}
Warning message:
In formatC(x = c(2.222, 3.333, 6.6666), format = "s", digits = 2, :
trasformo l'argomento in "character" in format="s"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With