% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/score_scales.R
\name{score_scales}
\alias{score_scales}
\title{Score defined scales from survey responses}
\usage{
score_scales(data, instrument, keep_items = TRUE, keep_meta = TRUE)
}
\arguments{
\item{data}{A \code{tibble} or \code{data.frame} of responses.}

\item{instrument}{An \code{sframe} object.}

\item{keep_items}{Logical. Whether to retain individual item columns in the
output. Defaults to \code{TRUE}.}

\item{keep_meta}{Logical. Whether to retain non-item columns (metadata) in
the output. Defaults to \code{TRUE}.}
}
\value{
A \code{data.frame} with scored scale columns appended. Scale columns are
named using the scale \code{id}.
}
\description{
Applies scale scoring rules from the instrument to response data. Handles
reverse coding, optional weighted composite score computation, and minimum
valid item thresholds. Returns a data frame with one scored column per
scale.
}
\examples{
cs    <- sf_choices("ag5", 1:5,
           c("Strongly disagree", "Disagree", "Neutral",
             "Agree", "Strongly agree"))
i1    <- sf_item("sat_1", "Item 1", type = "likert",
                 choice_set = "ag5", scale_id = "sat")
i2    <- sf_item("sat_2", "Item 2", type = "likert",
                 choice_set = "ag5", scale_id = "sat")
i3    <- sf_item("sat_3", "Item 3 (reverse)", type = "likert",
                 choice_set = "ag5", scale_id = "sat", reverse = TRUE)
scale <- sf_scale("sat", "Satisfaction",
                  items = c("sat_1", "sat_2", "sat_3"), min_valid = 2L)
instr <- sf_instrument("Demo", components = list(cs, i1, i2, i3, scale))

responses <- data.frame(
  sat_1 = c(4, 5, 3),
  sat_2 = c(4, 4, 3),
  sat_3 = c(2, 1, 3),
  stringsAsFactors = FALSE
)

scored <- score_scales(responses, instr)
scored$sat
}
\seealso{
\code{\link[=sf_scale]{sf_scale()}}, \code{\link[=reliability_report]{reliability_report()}}
}
