## Load the example `learnt` object calculated from the "penguins" dataset;
## variates: 'species' and 'bill_len'
learnt <- learntExample
## set of values for the variate "species";
## since this variate is of a nominal kind, all values are included
valuesSpecies <- vrtgrid(vrt = 'species', learnt = learnt)
print(valuesSpecies)
## create a set of values for the variate "bill length";
## this variate is continuous and rounded, only realistic values are included
valuesBill <- vrtgrid(vrt = 'bill_len', learnt = learnt)
range(valuesBill)
## let's take a subset of these values, to speed up computation
valuesBill <- valuesBill[seq(to = length(valuesBill), length.out = 65)]
## calculate the conditional probabilities for the 'bill_len' values above,
## given the values of 'species'
probs <- Pr(
Y = data.frame(bill_len = valuesBill),
X = data.frame(species = valuesSpecies),
learnt = learnt, parallel = 1
)
## plot the conditional probability distributions, and their variability
plot(probs)
Run the code above in your browser using DataLab