summaryFunctions: Summary functions

summaryFunctionsR Documentation

Summary functions

Description

Summary functions to use with crosstable() or anywhere else.

Usage

meansd(x, na.rm = TRUE, dig = 2, ...)

meanCI(x, na.rm = TRUE, dig = 2, level = 0.95, format = TRUE, ...)

mediqr(x, na.rm = TRUE, dig = 2, format = TRUE, ...)

minmax(x, na.rm = TRUE, dig = 2, ...)

nna(x)

Arguments

x

a numeric vector

na.rm

TRUE as default

dig

number of digits

...

params to pass on to format_fixed():

  • zero_digits (default=1): the number of significant digits for values rounded to 0 (set to NULL to keep the original 0 value)

  • only_round (default=FALSE): use round() instead of format_fixed()

level

the confidence level required

format

a sugar argument. If FALSE, the function returns a list instead of a formatted string

Value

a character vector

Functions

  • meansd(): returns mean and std error

  • meanCI(): returns mean and confidence interval

  • mediqr(): returns median and IQR

  • minmax(): returns minimum and maximum

  • nna(): returns number of observations and number of missing values

Fixed format

These functions use format_fixed() which allows to have trailing zeros after rounded values. In the case when the output of rounded values is zero, the use of the zero_digits argument allows to keep some significant digits for this specific case only.

Author(s)

Dan Chaltiel, David Hajage

See Also

format_fixed()

Examples

meansd(iris$Sepal.Length, dig=3)
meanCI(iris$Sepal.Length)
minmax(iris$Sepal.Length, dig=3)
mediqr(iris$Sepal.Length, dig=3)
nna(iris$Sepal.Length)

#arguments for format_fixed
x = iris$Sepal.Length/10000 #closer to zero

meansd(x, dig=3)
meansd(x, dig=3, zero_digits=NULL) #or NA
meansd(x, dig=3, only_round=TRUE)
options("crosstable_only_round"=TRUE)
meansd(x, dig=3, zero_digits=2)
options("crosstable_only_round"=NULL)
meanCI(mtcars2$x_date)

#dates
x = as.POSIXct(mtcars$qsec*3600*24 , origin="2010-01-01")
meansd(x)
minmax(x, date_format="%d/%m/%Y")


crosstable documentation built on Nov. 13, 2023, 1:08 a.m.