% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/vrtgrid.R
\name{vrtgrid}
\alias{vrtgrid}
\title{Create a grid of values for a variate}
\usage{
vrtgrid(vrt, learnt, length.out = 129)
}
\arguments{
\item{vrt}{Character: name of the variate, must match one of the names in the \code{metadata} file provided to the \code{\link[=learn]{learn()}} function.}

\item{learnt}{Either a character with the name of a directory or full path for a 'learnt.rds' object, produced by the \code{\link[=learn]{learn()}} function, or such an object itself.}

\item{length.out}{Numeric, positive (default 129): number of values to be created; used only for continuous, non-rounded variates (see \code{\link{metadata}}).}
}
\value{
A numeric or character vector of values.
}
\description{
This function creates a set of values for a variate, based on the information from data and metadata stored in a \code{learnt} object, created by the \code{\link[=learn]{learn()}} function. The set of values depends on the type of variate (nominal or continuous, rounded, and so on, see \link{metadata}). The range of values is chosen to include, and extend slightly beyond, the range observed in the data used in the \code{\link[=learn]{learn()}} function. Variate domains are always respected.
}
\examples{
## 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)

}
\seealso{
\code{\link[=learn]{learn()}}, which generates the \code{learnt} objects required by \code{vrtgrid()}.

\code{\link[=Pr]{Pr()}} to calculate probabilities and their variability.

\code{\link[=plot.probability]{plot.probability()}} to plot probabilities and quantiles calculated by \code{Pr()}.
}
