Learn R Programming

mosaic (version 0.8-18)

.qdata_old: The Data Distribution

Description

Density, distribution function, quantile function, and random generation from data.

cdata is a wrapper around qdata and determines endpoints of central probabilities rather than tail probabilities.

pdata computes cumulative probabilities from data.

rdata randomly samples from data. It is a wrapper around sample that unifies syntax.

ddata computes a probability mass function from data.

Usage

.qdata_old(p, vals, data = NULL, ...)

qdata_v(x, p = seq(0, 1, 0.25), ...)

qdata_f(x, ..., data, groups = NULL, ..fun.. = qdata_v)

qdata(p, vals, data = NULL, ...)

.cdata_old(p, vals, data = NULL, ...)

cdata_v(x, p = 0.95, ...)

cdata_f(x, ..., data, groups = NULL, ..fun.. = cdata_v)

cdata(p, vals, data = NULL, ...)

pdata_v(x, q, lower.tail = TRUE, ...)

pdata_f(x, ..., data, groups = NULL, ..fun.. = pdata_v)

pdata(q, vals, data = NULL, ...)

.pdata_old(q, vals, data = NULL, lower.tail = TRUE, ...)

rdata(n, vals, data = NULL, replace = TRUE, ...)

ddata(x, vals, data = NULL, log = FALSE, ...)

Arguments

p
a vector of probabilities
vals
a vector containing the data
data
a data frame in which to evaluate vals
groups
a grouping variable, typically the name of a variable in data
..fun..
a function. Most users will not need to change the default value.
...
additional arguments passed to quantile or sample
q
a vector of quantiles
lower.tail
a logical indicating whether to use the lower or upper tail probability
n
number of values to sample
replace
a logical indicating whether to sample with replacement
x
a vector of quantiles
log
a logical indicating whether the result should be log transformed

Value

  • For qdata, a vector of quantiles

    For pdata, a vector of probabilities

    For rdata, a vector of values sampled from vals

    For ddata, a vector of probabilities (empirical densities)

Details

qdata is a wrapper around quantile that makes the syntax more like the syntax for quantiles from theoretical distributions

Examples

Run this code
data(iris)
qdata(.5, Sepal.Length ~ Species, data=iris)
qdata(.5, ~Sepal.Length, groups=Species, data=iris)
qdata(.5, iris$Sepal.Length)
qdata(.5, Sepal.Length, data=iris)
qdata(.5, Sepal.Length, groups=Species, data=iris)
data(iris)
cdata(.5, iris$Sepal.Length)
cdata(.5, Sepal.Length, data=iris)
cdata_f(~Sepal.Length, data=iris, p=.5)
cdata_f(~Sepal.Length | Species, data=iris, p=.5)
data(iris)
pdata(3:6, iris$Sepal.Length)
pdata(3:6, Sepal.Length, data=iris)
data(iris)
rdata(10,iris$Species)
rdata(10, Species, data=iris)
data(iris)
ddata('setosa', iris$Species)
ddata('setosa', Species, data=iris)

Run the code above in your browser using DataLab