Kgosi
Kgosi

Reputation: 33

Rounding off to decimals

I have worked out a probability in r (equal to 1.7715e-06) and I would like to be able to view it to 10 decimal points. Does anybody know how to convert this to 10 decimal points? I've tried using the round() and signific() functions but they aren't useful.

I got this answer (1.7715e-06) using:

dbinom(11, 11, 0.3)

Upvotes: 0

Views: 61

Answers (2)

langtang
langtang

Reputation: 24832

You can also do this:

options("scipen"=999)

Then:

.3^11
[1] 0.00000177147

or

round(.3^11,10)
[1] 0.0000017715

or

dbinom(11,11,.3)
[1] 0.00000177147

or

round(dbinom(11,11,.3),10)
[1] 0.0000017715

Upvotes: 0

PaulS
PaulS

Reputation: 25383

A possible solution:

format(round(dbinom(11, 11, 0.3), 10), scientific = F)

#> [1] "0.0000017715"

Upvotes: 1

Related Questions