Use scientific notation with xtable in R

I pass data.frame to xxtable

dat.table <- xtable(dat[1:20,] ,digits=10) 

Instead of showing such numbers, I would rather use scientific notation. How can I do it?

looked, but all I found was R: formatting numbers in xtable , which is not the answer.

+8
r
source share
2 answers

Try:

 dat.table <- xtable(dat[1:20,] ,digits=-10) 

"If the digits are negative, the corresponding x values ​​are displayed in scientific format with the digits abs (digits)." xtable

+12
source share

If you want to use x10 ^ notation, use print and xtable . something like:

print(xtable(dat[1:10,1:7], display=c("s","s", "s","s","g","g","g","g")), math.style.exponents = TRUE)

where s is a string and g is used for scientific notation (only when saving space), math.style.exponents from print converted to x10 ^ format.

+2
source share

All Articles