This function computes the mean and standard deviation of a numeric vector and returns a formatted string with the mean and standard deviation, rounded to a specified number of decimal places.

meanSD(x, digits = 2)

Arguments

x

A numeric vector for which the mean and standard deviation are to be computed.

digits

An integer indicating the number of decimal places to which the results will be rounded. Defaults to 2.

Value

A character string containing the mean and standard deviation of x, formatted as 'mean (standard deviation)', each rounded to digits decimal places.

Examples

meanSD(c(10.5, 5.3, 7.8), digits = 3)
#> [1] "7.867 (2.601)"