% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/analyze.R
\name{get_correlations}
\alias{get_correlations}
\title{Calculate Question Correlations}
\usage{
get_correlations(
  survey,
  method = "pearson",
  format = "long",
  use = "pairwise.complete.obs",
  plot = FALSE
)
}
\arguments{
\item{survey}{A glint_survey object or data frame containing survey data}

\item{method}{Character string indicating the correlation method: "pearson"
(default), "spearman", or "kendall"}

\item{format}{Character string indicating output format: "long" for long format
with one row per question pair (default), or "matrix" for traditional
correlation matrix}

\item{use}{Character string indicating how to handle missing values, passed to
cor() function (default: "pairwise.complete.obs")}

\item{plot}{Logical. If \code{TRUE}, prints a correlation heatmap and returns
the data invisibly. Only supported when \code{format = "long"} (the
default); ignored with a warning when \code{format = "matrix"}. Requires
\pkg{ggplot2}. Default: \code{FALSE}.}
}
\value{
If format = "long", a tibble with columns:
\describe{
\item{question1}{First question text}
\item{question2}{Second question text}
\item{correlation}{Correlation coefficient}
\item{p_value}{P-value for test of correlation significance}
\item{n}{Number of complete pairs used in calculation}
}
If format = "matrix", a matrix with questions as rows and columns.
When \code{plot = TRUE} and \code{format = "long"}, the tibble is returned
invisibly after printing the plot.
}
\description{
Calculates correlations between all question response columns in the survey.
Supports multiple correlation methods and output formats.
}
\examples{
survey_path <- system.file("extdata", "survey_export.csv", package = "vivaglint")
survey <- read_glint_survey(survey_path, emp_id_col = "EMP ID")

# Get Pearson correlations in long format (default)
correlations <- get_correlations(survey)

# Get Spearman correlations
correlations_spearman <- get_correlations(survey, method = "spearman")

# Get correlation matrix
cor_matrix <- get_correlations(survey, format = "matrix")

# With correlation heatmap
if (requireNamespace("ggplot2", quietly = TRUE)) {
  get_correlations(survey, plot = TRUE)
}
}
