Skip to contents

This function reports the significant figures of a given mean together with its respective error term (for instance confidence interval or standard deviation).

Usage

signifig(x, error, data, style = "pm", na.digit = 2, ...)

Arguments

x

a numeric vector or data frame object containing the averaged values.

error

a numeric vector or data frame object containing the respective error terms.

data

a data frame containing the specified columns. If empty, x and error need to be given as numeric vectors.

style

a string specifying the output style to be used. The default style "pm" reports the results as "3 ± 6", while "par" results in outputs like "0.26 (0.02)". "siunitx" returns "0.26 (2)" which might be used together with xtable for automated LaTeX table outputs.

na.digit

an integer controlling to which significant digit the mean value should be rounded if the error is zero or no error data was provided.

...

arguments passed to prettyNum().

References

Taylor, J.R. (1997). Error analysis: the study of uncertainties in physical measurements. University Science Books, Sausalito, CA.

Author

Zacharias Steinmetz

Examples

signifig(c(0.28, 5, -31.6, 2.6, 2, NA, 27.1),
         c(0.688, 0.8, 11.6, 9.6, NA, 1.6, 0))
#> [1] "0.3 ± 0.7" "5.0 ± 0.8" "-30 ± 10"  "0 ± 10"    "2 ± NA"    "NA ± 2"   
#> [7] "27.1 ± 0"