errors {quantities} | R Documentation |
Set or retrieve measurement uncertainty to/from numeric vectors (extensions
to the errors package for quantities
and units
objects).
## S3 method for class 'units' errors(x) ## S3 method for class 'mixed_units' errors(x) ## S3 replacement method for class 'units' errors(x) <- value ## S3 replacement method for class 'mixed_units' errors(x) <- value ## S3 method for class 'units' set_errors(x, value = 0) ## S3 method for class 'mixed_units' set_errors(x, value = 0) ## S3 method for class 'units' errors_max(x) ## S3 method for class 'units' errors_min(x)
x |
a numeric object, or object of class |
value |
a numeric vector or |
For objects of class quantities
or units
, the
errors()
method returns a units
object that matches the units
of x
. Methods `errors<-`()
and set_errors()
assume that
the provided uncertainty (value
) has the same units as x
.
However, it is a best practice to provide a value
with explicit units.
In this way, uncertainty can be provided in different (but compatible) units,
and it will be automatically converted to the units of x
(see examples
below).
x <- set_units(1:5, m) errors(x) <- 0.01 # implicit units, same as x errors(x) errors(x) <- set_units(1, cm) # explicit units errors(x)