Produce summaries of various types of variables. Descriptive statistics
and plots are chosen automatically depending on the class of x.
The intention is to provide a fast but rich summary with minimal typing.
Compute descriptive statistics for a dichotomous variable. The plot method displays absolute and relative frequencies in horizontal bar plots.
Usage
desc(x, ...)
# S3 method for class 'list'
desc(x, ...)
# S3 method for class 'Desc.list'
print(x, ...)
# S3 method for class 'data.frame'
desc(x, ...)
# S3 method for class 'Desc'
print(x, ...)
# S3 method for class 'Desc'
plot(x, ...)
# S3 method for class 'Desc.factor'
plot(x, ...)
# S3 method for class 'logical'
desc(
x,
ord = "level",
conf.level = 0.95,
include_x = TRUE,
main = NULL,
verbose = NULL,
plotit = NULL,
digits = NULL,
...
)
# S3 method for class 'Desc.logical'
print(x, digits = NULL, ...)
# S3 method for class 'Desc.logical'
plot(x, ...)
# S3 method for class 'Desc.numeric'
print(x, digits = NULL, ...)
# S3 method for class 'Desc.numeric'
plot(x, main = x$meta$main, ...)
# S3 method for class 'Desc.AllNA'
print(x, ...)
# S3 method for class 'Desc.AllNA'
plot(x, ...)
# S3 method for class 'formula'
desc(
formula,
data,
subset,
na.action = na.pass,
main = NULL,
verbose = NULL,
plotit = NULL,
...
)Arguments
- x
a dichotomous numeric, integer, factor, character, or logical vector
- ...
further arguments passed to methods
- ord
order of the levels
- conf.level
confidence level of the interval (default 0.95). If set to
NA, no confidence interval is calculated.- include_x
logical; if
TRUE, the original vector is retained in the result- main
character string,
NULL, orNA, defining the main title. By default (main = NULL) the title will be composed as:(<class(es)>). If NA, no title is printed.- verbose
integer controlling verbosity of table output. One of
1(minimal),2(default),3(extensive). Applies to tables only.- plotit
logical. Should a plot be created? The plot type depends on the classes of the variables. Default can be defined by the option
plotit, if it does not exist then it's set toTRUE.- digits
number of digits used to format relative frequencies; the default can be set with
setDescToolsXOption(digits = x)- formula
formula describing the design. Depending on the function, supported forms include
y ~ 1,Pair(x, y) ~ 1,y ~ group,y ~ predictor, andy ~ treatment | block- data
optional matrix or data frame (or similar; see
stats::model.frame()) containing the variables in the formula. If omitted, variables are taken fromenvironment(formula)- subset
optional expression specifying a subset of observations to be used in the analysis
- na.action
function specifying how missing values are handled; passed to
bedrock::resolveFormula()
Value
an object of class "Desc" with a subclass determined by the
input, such as "Desc.numeric" or "Desc.qn"
an object of class c("Desc.logical", "Desc") with components:
afrqabsolute frequencies
rfrqmatrix of binomial estimates with columns:
estpoint estimate of the binomial proportion
lcilower confidence interval bound
uciupper confidence interval bound
Details
desc() is an S3 generic that computes basic descriptive statistics
depending on the class of its input. The result is an object of class
"desc" with a more specific subclass such as
"desc.numeric", "desc.factor" or "desc.data.frame".
For numeric vectors, summary statistics such as mean and standard deviation
are computed. For factors, frequency tables are returned. For data frames,
desc() is applied column-wise.
desc is a generic function. It dispatches to the
method of the class of its first argument.
Typing ?desc + TAB at the prompt lists all available methods.
You usually call desc(x), but direct calls like
desc.numeric(x) are also possible.
Univariate descriptions
Numeric variables:
desc.numeric()Factors and character vectors:
desc.factor()Boolean variables:
desc.logical()Contingency tables:
desc.table()Dates:
desc.Date()Time series:
desc.ts()
Bivariate descriptions
numeric ~ numeric:
desc.nn()numeric ~ qualitative:
desc.nq()qualitative ~ numeric:
desc.qn()qualitative ~ qualitative:
desc.qq()(wrapper arounddesc.table())
Design
The desc system separates:
computation (internal
.desc_*functions)printing (
print.Desc.*)visualization (
plot.Desc.*)
Description of a dichotomous variable. This can either be a logical
vector, a factor with two levels or a numeric variable with only two unique
values. The confidence levels for the relative frequencies are calculated by
lumen::binomCI(), method "Wilson" on a confidence
level defined by conf.level.
Dichotomous variables can be condensed into a compact graphical representation. The method calculates frequencies and binomial confidence intervals and can display them as a dot plot with error bars.
See also
pharos::plotPropCI() for graphical display
Other desc:
desc.Date(),
desc.factor(),
desc.nn,
desc.nq,
desc.numeric(),
desc.qn,
desc.qq,
desc.table(),
desc.ts()
