1

I know it might seem as a trivial question but I tried really hard to find solution and it was impossible. Assume I have a data frame like this where one column contatins big numbers:

Id    Value
1     2158456456456.78
2     123354554.24
3     72323211215.77

I want to put that data frame into latex document using function xtable but I don't want the table to display the numbers like above but in a formatted way like this:

Id                   Value
1     2 158 456 456 456.78
2           123 354 554.24
3        72 323 211 215.77

Any ideas?

Michał
  • 273
  • 1
  • 3
  • 13

3 Answers3

3

You can pass the arguments for formatC directly to print.xtable:

print(xtable(df1), type = "latex", format.args=list(big.mark = " ")) 
bergant
  • 7,122
  • 1
  • 20
  • 24
1
format(2158456456457,big.mark=" ",scientific=F)
Prasanna Nandakumar
  • 4,295
  • 34
  • 63
0

you can try

options(scipen = 100) # to remove exponential notation
df$val <- prettyNum(df$Value,  big.mark=" ")
  Id         Value               val
1  1 2158456456457 2 158 456 456 457
2  2     123354554       123 354 554
3  3   72323211216    72 323 211 216

'scipen': A penalty to be applied when deciding to print numeric values in fixed or exponential notation.

Mamoun Benghezal
  • 5,264
  • 7
  • 28
  • 33