I pass a data.frame to xtable
dat.table <- xtable(dat[1:20,] ,digits=10)
Instead of displaying digits like that, I would prefer to use scientific notation. How would I do that?
had a look but all I found was R: formatting the digits in xtable which isn't the answer it seems.
Remove notation in the entire R session You can disable scientific notation in the entire R session by using the scipen option. Global options of your R workspace. Use options(scipen = n) to display numbers in scientific format or fixed.
Method 1: Using scipen option In order to eliminate the exponential notation of the integer, we can use the global setting using options() method, by setting the scipen argument, that is options(scipen = n).
To set the use of scientific notation in your entire R session, you can use the scipen option. From the documentation ( ? options ): 'scipen': integer.
Try:
dat.table <- xtable(dat[1:20,] ,digits=-10)
"If values of digits are negative, the corresponding values of x are displayed in scientific format with abs(digits) digits." xtable
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