Plot correlation matrix

# create data frame with 5 random variables
mydf <- data.frame(cbind(runif(10),
                         runif(10),
                         runif(10),
                         runif(10),
                         runif(10)))

# plot correlation matrix using circles
sjp.corr(mydf)
## Computing correlation using spearman-method with listwise-deletion...
## Warning: Non Lab interpolation is deprecated
## Warning: Removed 10 rows containing missing values (geom_point).

plot of chunk sjp.corr

# plot correlation matrix using square tiles without diagram background
sjp.corr(mydf, type = "tile")
## Computing correlation using spearman-method with listwise-deletion...
## Warning: Non Lab interpolation is deprecated

plot of chunk sjp.corr

# -------------------------------
# Data from the EUROFAMCARE sample dataset
# -------------------------------
library(sjmisc)
data(efc)

# retrieve variable and value labels
varlabs <- get_label(efc)

# create data frame
vars.index <- c(1, 4, 15, 19, 20, 21, 22, 24, 25)
mydf <- data.frame(efc[, vars.index])
colnames(mydf) <- varlabs[vars.index]

# show legend
sjp.corr(mydf, type = "tile", hideLegend = FALSE)
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Computing correlation using spearman-method with listwise-deletion...
## Warning: Non Lab interpolation is deprecated

plot of chunk sjp.corr

# -------------------------------
# auto-detection of labels
# -------------------------------
# blank theme
sjp.setTheme(theme = "blank", axis.angle.x = 90)
sjp.corr(efc[, vars.index])
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Warning in cor.test.default(df[[i]], df[[j]], alternative =
## "two.sided", : Cannot compute exact p-value with ties
## Computing correlation using spearman-method with listwise-deletion...
## Warning: Non Lab interpolation is deprecated
## Warning: Removed 36 rows containing missing values (geom_point).

plot of chunk sjp.corr