Density, distribution function, quantile function, and random generation from data.
qdata(formula, p = seq(0, 1, 0.25), data = NULL, ...)
cdata(formula, p = 0.95, data = NULL, ...)
pdata(formula, q, data = NULL, ...)
rdata(formula, n, data = NULL, ...)
ddata(formula, q, data = NULL, ...)
a formula or a vector
a vector of probabilities
a data frame in which to evaluate formula
additional arguments passed to quantile
or sample
a vector of quantiles
number of values to sample
For qdata
, a vector of quantiles
for cdata
, a data frame giving
upper and lower limits and the central proportion requested
For pdata
, a vector of probabilities
For rdata
, a vector of sampled values.
For ddata
, a vector of probabilities (empirical densities)
data(penguins, package = "palmerpenguins")
qdata(flipper_length_mm ~ species, 0.5, data = penguins)
#> species 50%
#> 1 Adelie 190
#> 2 Chinstrap 196
#> 3 Gentoo 216
qdata( ~ flipper_length_mm, p = 0.5, groups = species, data = penguins)
#> species 50%
#> 1 Adelie 190
#> 2 Chinstrap 196
#> 3 Gentoo 216
qdata(penguins$flipper_length_mm, p = 0.5)
#> 50%
#> 197
qdata( ~ flipper_length_mm, p = 0.5, data = penguins)
#> 50%
#> 197
qdata( ~ flipper_length_mm, p = 0.5, groups = species, data = penguins)
#> species 50%
#> 1 Adelie 190
#> 2 Chinstrap 196
#> 3 Gentoo 216
data(penguins, package = 'palmerpenguins')
cdata(penguins$flipper_length_mm, 0.5)
#> lower upper central.p
#> 25% 190 213 0.5
cdata( ~ flipper_length_mm, 0.5, data = penguins)
#> lower upper central.p
#> 25% 190 213 0.5
cdata( ~ flipper_length_mm, 0.5, data = penguins)
#> lower upper central.p
#> 25% 190 213 0.5
cdata( ~ flipper_length_mm | species, data = penguins, p = .5)
#> species lower upper central.p
#> 1 Adelie 186 195 0.5
#> 2 Chinstrap 191 201 0.5
#> 3 Gentoo 212 221 0.5
data(penguins, package = 'palmerpenguins')
pdata(penguins$flipper_length_mm, 3:6)
#> [1] 0 0 0 0
pdata( ~ flipper_length_mm, 3:6, data = penguins)
#> [1] 0 0 0 0
data(penguins, package = 'palmerpenguins')
rdata(penguins$species, 10)
#> [1] Chinstrap Adelie Adelie Adelie Chinstrap Adelie Gentoo
#> [8] Adelie Adelie Gentoo
#> Levels: Adelie Chinstrap Gentoo
rdata( ~ species, n = 10, data = penguins)
#> [1] Gentoo Gentoo Gentoo Chinstrap Adelie Adelie Chinstrap
#> [8] Adelie Chinstrap Gentoo
#> Levels: Adelie Chinstrap Gentoo
rdata(flipper_length_mm ~ species, n = 5, data = penguins)
#> species rdata_v1 rdata_v2 rdata_v3 rdata_v4 rdata_v5
#> 1 Adelie 180 189 184 193 185
#> 2 Chinstrap 196 197 190 195 197
#> 3 Gentoo 220 221 219 214 220
data(penguins, package = 'palmerpenguins')
ddata(penguins$species, 'setosa')
#> setosa
#> 0
ddata( ~ species, 'setosa', data = penguins)
#> setosa
#> 0