Round off the value that depends on the first significant digit of the uncertainty

I am wondering how I would get around the value, depending on the uncertainty of values.

For example:

If the value 0.2563

, and the uncertainty in this value 0.007423

. I would like to round the value to 0.256+/-0.007

.

+3


source to share


2 answers


I think you can try

x=0.2563
y=0.007423
paste0(round(x,digits = 3),"+-",round(y,digits = 3))
#[1] "0.256+-0.007

      



Or with a plus-minus symbol:

paste0(round(x,digits = 3),"\u00B1",round(y,digits = 3))
#[1] "0.256±0.007"

      

+4


source


How about a simple one:

val <- x + c(-1,1)*y
val
[1] 0.248877 0.263723
round(val, digits = 4)
[1] 0.2489 0.2637

      

Or there could be another way:



x + c(-1, 1)* round(y, 3)
[1] 0.2493 0.2633

      

I believe it depends on what level of precision you need and which items ( x

or y

) may or may not be rounded.

+1


source







All Articles