Error using corrplot
I think the problem is that you are plotting the data frame instead of the correlation matrix. Try to change the last line to this:
corrplot(cor(df2), method="shade",shade.col=NA, tl.col="black", tl.srt=45)
The function cor calculates the correlation matrix, which is what you need to plot
Another option is to break it up into two lines of code.
df2 <- cor(df, use = "na.or.complete")corrplot(df2, method="shade",shade.col=NA, tl.col="black", tl.srt=45)
I'd run a simple corrplot (e.g. corrplot.mixed(df2)) make sure it works, then get into the fine tuning and aesthetics.
In order to use the corrplot
package for heatmap plots you should pass your data.frame
to a matrix
and also use the is.corr
argument.
df2 <- as.matrix(df2)corrplot(df2, is.corr=FALSE)