Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use scientific notation with xtable in R

Tags:

r

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.

like image 869
cianius Avatar asked Nov 24 '14 10:11

cianius


People also ask

How do you put a number in scientific notation in R?

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.

How do I stop e+ in R?

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).

How do I change the scientific number format in R?

To set the use of scientific notation in your entire R session, you can use the scipen option. From the documentation ( ? options ): 'scipen': integer.


1 Answers

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

like image 136
Mikael Jumppanen Avatar answered Sep 20 '22 10:09

Mikael Jumppanen