ts/man/ts_factor.Rd
2025-02-24 14:35:02 +13:00

28 lines
654 B
R

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/types.R
\name{ts_factor}
\alias{ts_factor}
\title{Typed factor}
\usage{
ts_factor(levels = NULL)
}
\arguments{
\item{levels}{A character vector of levels (optional).}
}
\value{
A ts object that accepts factors with the specified levels.
}
\description{
Factors are integers with labels. On the JS side, these are \emph{always} represented as a string array (even if only one value - yay!).
}
\examples{
x <- ts_factor(levels = c("a", "b"))
x$check(factor("a", levels = c("a", "b")))
\dontrun{
# this will fail
x$check("a")
x$check(factor("c", levels = c("a", "b", "c")))
}
}