## Load the example `learnt` object calculated from the "penguins" dataset;
## variates: 'species' and 'bill_len'
learnt <- learntExample
## ## Example 1:
## Generate 10 values of the 'species' variate,
## according to the frequency distribution estimated from the data
datapoints <- rPr(
n = 10,
Ynames = 'species',
learnt = learnt
)
c(datapoints)
## ## Example 2:
## Generate 5 joint values of the 'species' and 'bill_len' variates.
datapoints <- rPr(
n = 5,
Ynames = c('species', 'bill_len'),
learnt = learnt
)
print(datapoints, row.names = FALSE) ## row names give MCMC information
## ## Example 3:
## Generate 5 values of the 'species' variate,
## for the subpopulation of penguins having bill length shorter than 40 mm
datapoints <- rPr(
n = 5,
Ynames = 'species',
X = data.frame(bill_len = 40),
tails = list(bill_len = -1),
learnt = learnt
)
c(datapoints)
Run the code above in your browser using DataLab