quant: Quantiles for a Continuous variable

Description Usage Arguments Value See Also Examples

Description

The function provides quantiles for a continuous variable, possibly according to levels of one or several categorical variables.

Usage

1
2
3
4
  quant(formula, data, probs = NULL, digits = 3)
  ## S3 method for class 'quant'
print(x, ...)
  

Arguments

formula

A formula with the numerical variable on the left-hand side and the categorical variable(s) on the right-hand side. When several categorical variables are included, they must be separated by a +, i.e., interactions (denoted by symbols : or *) are not allowed.

data

A data frame containing the variables indicated in the formula.

probs

A numeric vector of probabilities with values in [0,1].

digits

A scalar indicating the number of decimal digits left when rounding the result of the statictics.

x

An object of class “quant”.

...

Further arguments to be passed to the functions.

Value

A list with components CALL, tab, nbfact and digits. Component tab is the data frame built according to the formula and function used in the call.

See Also

summary, quantile, aggregate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
tmp <- data.frame(
    f1 = c(NA, rep("a", 2), rep("b", 5), NA, "a", "a"),
    f2 = rep(c("c", "d"), times = c(5, 6)),
    f3 = rep(c("e", NA, "f"), times = c(4, 1, 6)),
    y1 = c(rnorm(n = 9, mean = 10, sd = 5), NA, 2.1)
    )
tmp

quant(formula = y1 ~ f1, data = tmp)
quant(formula = y1 ~ f1, data = tmp, digits = 1)
quant(formula = y1 ~ f1,  data = tmp, probs = c(0.02, 0.50, 0.98))
tab <- quant(formula = y1 ~ f1, data = tmp)
tab$tab

quant(formula = y1 ~ 1, data = tmp)

quant(formula = y1 ~ f1 + f2, data = tmp)

  

tdisplay documentation built on May 2, 2019, 4:46 p.m.