Support for measurement errors in R vectors, matrices and arrays:
automatic uncertainty propagation and reporting.
Documentation about 'errors' is provided in the paper by Ucar, Pebesma &
Azcorra (2018,
The errors package provides support for easurement errors in R vectors, matrices and arrays: automatic uncertainty propagation and reporting.
Install the release version from CRAN:
install.packages("errors")
The installation from GitHub requires the remotes package.
# install.packages("remotes")remotes::install_github("r-quantities/errors")
library(errors)x <- 1:10errors(x) <- 0.1x#> Errors: 0.1 0.1 0.1 0.1 0.1 ...#> [1] 1 2 3 4 5 6 7 8 9 10(x <- set_errors(1:10, 1:10 * 0.05))#> Errors: 0.05 0.10 0.15 0.20 0.25 ...#> [1] 1 2 3 4 5 6 7 8 9 10(df <- data.frame(x, 3*x, x^2, sin(x), cumsum(x)))#> Warning: In 'Ops' : non-'errors' operand automatically coerced to an#> 'errors' object with no uncertainty#> x X3...x x.2 sin.x. cumsum.x.#> 1 1.00(5) 3.0(2) 1.0(1) 0.84(3) 1.00(5)#> 2 2.0(1) 6.0(3) 4.0(4) 0.91(4) 3.0(1)#> 3 3.0(2) 9.0(5) 9.0(9) 0.1(1) 6.0(2)#> 4 4.0(2) 12.0(6) 16(2) -0.8(1) 10.0(3)#> 5 5.0(2) 15.0(8) 25(2) -0.96(7) 15.0(4)#> 6 6.0(3) 18.0(9) 36(4) -0.3(3) 21.0(5)#> 7 7.0(4) 21(1) 49(5) 0.7(3) 28.0(6)#> 8 8.0(4) 24(1) 64(6) 0.99(6) 36.0(7)#> 9 9.0(4) 27(1) 81(8) 0.4(4) 45.0(8)#> 10 10.0(5) 30(2) 100(10) -0.5(4) 55(1)format(df, notation="plus-minus")#> x X3...x x.2 sin.x. cumsum.x.#> 1 1.00 ± 0.05 3.0 ± 0.2 1.0 ± 0.1 0.84 ± 0.03 1.00 ± 0.05#> 2 2.0 ± 0.1 6.0 ± 0.3 4.0 ± 0.4 0.91 ± 0.04 3.0 ± 0.1#> 3 3.0 ± 0.2 9.0 ± 0.5 9.0 ± 0.9 0.1 ± 0.1 6.0 ± 0.2#> 4 4.0 ± 0.2 12.0 ± 0.6 16 ± 2 -0.8 ± 0.1 10.0 ± 0.3#> 5 5.0 ± 0.2 15.0 ± 0.8 25 ± 2 -0.96 ± 0.07 15.0 ± 0.4#> 6 6.0 ± 0.3 18.0 ± 0.9 36 ± 4 -0.3 ± 0.3 21.0 ± 0.5#> 7 7.0 ± 0.4 21 ± 1 49 ± 5 0.7 ± 0.3 28.0 ± 0.6#> 8 8.0 ± 0.4 24 ± 1 64 ± 6 0.99 ± 0.06 36.0 ± 0.7#> 9 9.0 ± 0.4 27 ± 1 81 ± 8 0.4 ± 0.4 45.0 ± 0.8#> 10 10.0 ± 0.5 30 ± 2 100 ± 10 -0.5 ± 0.4 55 ± 1sum(x)#> 55(1)print(mean(x), digits=3)#> 5.500(957)
?GUM.H.3
).NA
as
NA_real_
(#30).?`errors-package`
and provide new examples for
?correl
(aed40eb).Summary.errors
to deal with named arguments (dd4607b).as.list
for errors
objects (7aff546).correl
and
covar
methods set and retrieve pairwise correlations or covariances,
respectively, between errors
objects, thereby completing the full
first-order Taylor series method of propagation of uncertainty.?GUM.H.2
and examples
under ?correl
).all.equal
for errors
objects (as part of #26), which returns
TRUE
for different (different internal identifier) objects with the same
quantity values and uncertainty. To compare whether two variables are exactly
the same object, identical
should be used instead.pillar
representation (14df89b).drop_errors
method drops errors
class and attributes. Equivalent to
setting a NULL
error (#23).pillar_shaft
for tidy tibble
printing and improve type_sum
(700f1aa).Ops
warnings once (#22).print
method (2c252d9).cbind
/rbind
column/row name parsing for named arguments (b8ea6b5).scipen
option (9299551).min
, max
, range
return numeric, including the error: value minus error,
value plus error and (min, max)
respectively (#18).structure
instead of set_errors
internally (#20).rbind
, cbind
, as.data.frame
for errors
objects (#21).Inf
, NaN
and NA
values default to Inf
, NaN
and NA
errors
respectively (#10).errors
objects (#13).set_errors
(#14).tibble
printing (#15).digits
into account for errors in vector display (#7).