Learn R Programming

prova (version 1.0.0)

print.probability: Print an object of class "probability"

Description

This base::print() method is a utility to display selected elements of a "probability" object obtained with Pr(); typically its posterior probabilies (element $values) and their variabilities (element $quantiles). If the Y or X variates are joint variates, this method also allow to display only selected values of them

Usage

# S3 method for probability
print(x, elements = NULL, subset = NULL, digits = TRUE, ...)

Value

Its x argument, invisibly; see base::print().

Arguments

x

Object of class "probability", obtained with Pr().

elements

character or integer vector, or NULL (default): elements of the "probability" object to display. The syntax is the same as with [. If NULL, the elements $values and $quantiles are displayed together in a special way.

subset

Named list or named vector: which variate values to display. For the variates corresponding to the names in this list, only the vector of values corresponding to that variate is displayed.

digits

positive number or NULL or TRUE (default): minimal number of significant digits, see base::print.default(). If value is TRUE, then the significant digits for elements $values and $quantiles are determined from their respective $values.MCaccuracy and $quantiles.MCaccuracy elements of the probability object, see Pr(); whereas $samples elements use 2 significant digits.

...

Other parameters to be passed to base::print().

See Also

Pr() to calculate posterior probabilities and quantiles.

plot.probability() to plot probabilities and quantiles calculated by `Pr()'. hist.probability() to plot the variability of the probabilities as a distribution.

Examples

Run this code
## Load the example `learnt` object calculated from the "penguins" dataset;
## variates: 'species' and 'bill_len'
learnt <- learntExample

## Calculate the 3 x 2 probabilities for the 3 species
## given bill-lengths of 43 mm and 44 mm

Y <- data.frame(species = c('Adelie', 'Chinstrap', 'Gentoo'))
X <- data.frame(bill_len = c(43, 44))

probs <- Pr(Y = Y, X = X, learnt = learnt, parallel = 1)

## display the values and variabilities of these probabilities
print(probs)

## diplay 'values' only, and only for the species value 'Gentoo'
print(probs, elements = 'values', subset = list(species = 'Gentoo'))

Run the code above in your browser using DataLab