Learn R Programming

ggquickeda (version 0.1.0)

stats.default: Compute some basic descriptive statistics.

Description

Values of type factor, character and logical are treated as categorical. For logicals, the two categories are given the labels `Yes` for TRUE, and `No` for FALSE. Factor levels with zero counts are retained.

Usage

stats.default(x, useNA = NULL)

Arguments

x

A vector or numeric, factor, character or logical values.

useNA

For categorical x, should missing values be treated as a category?

Value

A list. For numeric x, the list contains the numeric elements:

  • N: the number of non-missing values

  • NMISS: the number of missing values

  • MEAN: the mean of the non-missing values

  • SD: the standard deviation of the non-missing values

  • MIN: the minimum of the non-missing values

  • MEDIAN: the median of the non-missing values

  • MAX: the maximum of the non-missing values

  • Q25: the lower quartile of the non-missing values

  • Q75: the upper quartile of the non-missing values

  • IQR: the inter-quartile range of the non-missing values

  • CV: the percent coefficient of variation of the non-missing values

  • GMEAN: the geometric mean of the non-missing values if non-negative, or NA

  • GCV: the percent geometric coefficient of variation of the non-missing values if non-negative, or NA

If x is categorical (i.e. factor, character or logical), the list contains a sublist for each category, where each sublist contains the numeric elements:

  • FREQ: the frequency count

  • PCT: the percent relative frequency

Examples

Run this code
# NOT RUN {
x <- exp(rnorm(100, 1, 1))
stats.default(x)

y <- factor(sample(0:1, 99, replace=TRUE), labels=c("Female", "Male"))
y[1:10] <- NA
stats.default(y)
stats.default(is.na(y))

# }

Run the code above in your browser using DataLab