# create data frame with 5 random variables
df <- as.data.frame(cbind(rnorm(10), rnorm(10), rnorm(10), rnorm(10), rnorm(10)))
# plot correlation matrix using circles
sjp.corr(df)
# plot correlation matrix using square tiles without diagram background
sjp.corr(df, type="tile")
# -------------------------------
# Data from the EUROFAMCARE sample dataset
# -------------------------------
data(efc)
# retrieve variable and value labels
varlabs <- get_var_labels(efc)
# create data frame
vars.index <- c(1, 4, 15, 19, 20, 21, 22, 24, 25)
df <- as.data.frame(efc[, vars.index])
colnames(df) <- varlabs[vars.index]
# show legend
sjp.corr(df, type="tile", hideLegend=FALSE)
# -------------------------------
# auto-detection of labels
# -------------------------------
efc <- set_var_labels(efc, varlabs)
# blank theme
sjp.setTheme(theme = "blank", axis.angle.x = 90)
sjp.corr(efc[, vars.index])
Run the code above in your browser using DataLab