% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/import.R
\name{join_attributes}
\alias{join_attributes}
\title{Join Employee Attributes to Survey Data}
\usage{
join_attributes(survey, attribute_source, emp_id_col = NULL)
}
\arguments{
\item{survey}{A \code{glint_survey} object or data frame containing survey data}

\item{attribute_source}{Either a character string file path to a CSV file, or
a data frame containing employee attributes. All columns are coerced to
character to avoid type conflicts during joining.}

\item{emp_id_col}{Character string specifying the employee ID column name.
Must match the column name in both the survey data and the attribute data.
When \code{survey} is a \code{glint_survey} object this defaults to
\code{survey$metadata$emp_id_col} (set at import via
\code{read_glint_survey()}), so you can omit this argument if you loaded
the survey with the correct \code{emp_id_col}.}
}
\value{
If \code{survey} is a \code{glint_survey} object, returns an enriched
\code{glint_survey} with the attribute columns appended to \code{$data} and
the names of all joined attribute columns stored in
\code{$metadata$attribute_cols}. If \code{survey} is a plain data frame,
returns the joined data frame.

Respondents with no match in the attribute data will have \code{NA} for all
attribute columns; a message is emitted indicating how many were affected.
}
\description{
Reads employee attribute data from a CSV file or data frame and joins it to
a survey object by employee ID. Returns an enriched \code{glint_survey}
object that can be passed directly to \code{analyze_by_attributes()} or any
other package function, eliminating the need to re-read and re-join the
attribute file on every call.
}
\examples{
survey_path <- system.file("extdata", "survey_export.csv", package = "vivaglint")
attr_path <- system.file("extdata", "employee_attributes.csv", package = "vivaglint")
survey <- read_glint_survey(survey_path, emp_id_col = "EMP ID")

survey_enriched <- join_attributes(survey, attr_path, emp_id_col = "EMP ID")
results <- analyze_by_attributes(survey_enriched, scale_points = 5,
                                 attribute_cols = "Department")
}
