# example plotting the correlation matrix from the
# mtcars dataset
corplot(cor(mtcars))
dat <- as.matrix(iris[, 1:4])
# randomly set 25% of the data to missing
set.seed(10)
dat[sample(length(dat), length(dat) * .25)] <- NA
cor(dat, use = "pair")
cor(dat, use = "complete")
# create a summary of the data (including coverage matrix)
sdat <- SEMSummary(~ ., data = dat, use = "pair")
str(sdat)
# using the plot method for SEMSummary (which basically just calls corplot)
## getting correlations above diagonal and p values below diagonal#'
plot(sdat)
## get correlations only
plot(sdat, type = "cor")
## showing coverage
plot(sdat, type = "coverage")
# use the control.grobs argument to adjust the coverage scaling
# to go from 0 to 1 rather than the range of coverage
corplot(x = sdat$sSigma, coverage = sdat$coverage,
type = "coverage",
control.grobs = list(area = quote(scale_size_area(limits = c(0, 1))))
)
# also works with plot() on a SEMSummary
plot(x = sdat, type = "coverage",
control.grobs = list(area = quote(scale_size_area(limits = c(0, 1))))
)
rm(dat, sdat)
Run the code above in your browser using DataLab