View source: R/view_rmcorr_shiny.R
| view_rmcorr_shiny | R Documentation |
Launches a dedicated Shiny gadget for repeated-measures correlation matrix
objects of class "rmcorr_matrix". The viewer combines the correlation
heatmap with a pairwise scatterplot panel that rebuilds the corresponding
two-variable "rmcorr" fit for user-selected variables.
view_rmcorr_shiny(x, title = NULL, default_max_vars = 40L)
x |
An object of class |
title |
Optional character title shown at the top of the gadget. |
default_max_vars |
Integer; maximum number of variables pre-selected in the heatmap view when the app opens. Defaults to 40. |
This helper requires the shiny and shinyWidgets
packages at runtime and will optionally use plotly for the heatmap
when available. The pairwise panel reuses the package's regular
plot.rmcorr() method, so the Shiny scatterplot matches the standard
pairwise repeated-measures correlation plot. To rebuild pairwise fits from a
returned "rmcorr_matrix" object, the matrix must have been created
with keep_data = TRUE.
Invisibly returns NULL; the function is called for its side
effect of launching a Shiny gadget.
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.