% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sf_branch.R
\name{sf_branch}
\alias{sf_branch}
\title{Define a branching rule}
\usage{
sf_branch(
  item_id,
  depends_on,
  operator = c("==", "!=", "\%in\%", ">", ">=", "<", "<="),
  value,
  action = c("show", "hide")
)
}
\arguments{
\item{item_id}{Character. The \code{id} of the item whose visibility this rule
controls.}

\item{depends_on}{Character. The \code{id} of the item whose response value
triggers this rule.}

\item{operator}{Character. The comparison operator. One of \code{"=="}, \code{"!="},
\code{"\%in\%"}, \code{">"}, \code{">="}, \code{"<"}, or \code{"<="}.}

\item{value}{The value to compare against the response to \code{depends_on}.
For \code{"\%in\%"}, supply a character or numeric vector.}

\item{action}{Character. What to do when the condition is met. Either
\code{"show"} (default) or \code{"hide"}.}
}
\value{
An object of class \code{sf_branch} (a named list).
}
\description{
Creates a single-condition branching rule that shows or hides a survey item
depending on the value of a preceding item. In v0.1, only single-condition
rules are supported. Multi-condition AND/OR logic is planned for a later
release.
}
\examples{
# Show an open-text follow-up only when the respondent selects "Other"
rule <- sf_branch(
  item_id    = "gender_other",
  depends_on = "gender",
  operator   = "==",
  value      = "other",
  action     = "show"
)
}
\seealso{
\code{\link[=sf_instrument]{sf_instrument()}}, \code{\link[=validate_sframe]{validate_sframe()}}
}
