% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/view_rmcorr_shiny.R
\name{view_rmcorr_shiny}
\alias{view_rmcorr_shiny}
\title{Interactive Shiny Viewer for Repeated-Measures Correlation}
\usage{
view_rmcorr_shiny(x, title = NULL, default_max_vars = 40L)
}
\arguments{
\item{x}{An object of class \code{"rmcorr_matrix"} or a named list of such
objects.}

\item{title}{Optional character title shown at the top of the gadget.}

\item{default_max_vars}{Integer; maximum number of variables pre-selected
in the heatmap view when the app opens. Defaults to 40.}
}
\value{
Invisibly returns \code{NULL}; the function is called for its side
effect of launching a Shiny gadget.
}
\description{
Launches a dedicated Shiny gadget for repeated-measures correlation matrix
objects of class \code{"rmcorr_matrix"}. The viewer combines the correlation
heatmap with a pairwise scatterplot panel that rebuilds the corresponding
two-variable \code{"rmcorr"} fit for user-selected variables.
}
\details{
This helper requires the \pkg{shiny} and \pkg{shinyWidgets}
packages at runtime and will optionally use \pkg{plotly} for the heatmap
when available. The pairwise panel reuses the package's regular
\code{plot.rmcorr()} method, so the Shiny scatterplot matches the standard
pairwise repeated-measures correlation plot. To rebuild pairwise fits from a
returned \code{"rmcorr_matrix"} object, the matrix must have been created
with \code{keep_data = TRUE}.
}
\examples{
if (interactive()) {
  set.seed(2026)
  n_subjects <- 20
  n_rep <- 4
  subject <- rep(seq_len(n_subjects), each = n_rep)
  subj_eff_x <- rnorm(n_subjects, sd = 1.5)
  subj_eff_y <- rnorm(n_subjects, sd = 2.0)
  within_signal <- rnorm(n_subjects * n_rep)

  dat <- data.frame(
    subject = subject,
    x = subj_eff_x[subject] + within_signal + rnorm(n_subjects * n_rep, sd = 0.2),
    y = subj_eff_y[subject] + 0.8 * within_signal + rnorm(n_subjects * n_rep, sd = 0.3),
    z = subj_eff_y[subject] - 0.4 * within_signal + rnorm(n_subjects * n_rep, sd = 0.4)
  )

  fit_mat <- rmcorr(
    dat,
    response = c("x", "y", "z"),
    subject = "subject",
    keep_data = TRUE
  )
  view_rmcorr_shiny(fit_mat)
}

}
