Learn R Programming

DemographicTable (version 0.1.8)

summaryText: Summary Text

Description

Provide the summary text of an R object

Usage

summaryText(x, fmt, ...)

# S3 method for default summaryText(x, fmt = "%.2f", ...)

# S3 method for factor summaryText(x, fmt = "%.1f", useNA = c("no", "always"), ...)

# S3 method for ordered summaryText(x, fmt = "%.1f", useNA = c("no", "always"), ...)

# S3 method for character summaryText(x, ...)

# S3 method for logical summaryText(x, fmt = "%.1f", ...)

Value

Function summaryText returns a character scalar.

Arguments

x

an R object

fmt

character scalar, format string, see sprintf

...

additional parameters, currently not in use

useNA

character scalar, 'no' (default) or 'always', see table

Examples

Run this code
x = rpois(n = 20L, lambda = 2)
x[sample.int(length(x), 3L)] = NA_integer_
summaryText(x)

# factor 
x = state.region
x[2L] = NA_integer_
summaryText(x)

# binary
summaryText(c(TRUE, FALSE, TRUE, NA))
summaryText(c(TRUE, FALSE, TRUE))
summaryText(c(FALSE, FALSE, NA))
summaryText(c(FALSE, FALSE, FALSE))
summaryText(c(NA, NA, NA))

Run the code above in your browser using DataLab