[![enter image description here][1]][1]I have a data set with Yes No values for Cancer and underlying risk factors (e.g.agefirstchild). Below an example of the data set
set.seed(42)
cancer <- sample(c("yes", "no"), 200, replace=TRUE)
agegroup <- sample(c("35-39", "40-44", "45-49"), 200, replace=TRUE)
agefirstchild <- sample(c("Age < 30", "Age 30 or greater", "nullipareous"), 200, replace=TRUE)
dat <- data.frame(cancer, agegroup, agefirstchild)
I would like to run a Spearman correlation plot that looks like this[![enter image description here][2]][2]
This plot comes from the corrplot package. But when I apply this code for my data set it gives me an error. Error in matrix(if (is.null(value)) logical() else value, nrow = nr, dimnames = list(rn, : length of 'dimnames' [3] not equal to array extent Images are available at links under code, and below the description:
[![Corrplot][2]][2]
[![Correlation plot from example below][3]][3]
And where in the code can I add the method, I need Spearman? It doesn't necessarily need to be exactly the same as below but similar format and with values in the plot
corrplot(dat, method = "color", col = col(200),
type = "upper", order = "hclust", number.cex = .7,
addCoef.col = "black",
tl.col = "black", tl.srt = 90,
p.mat = p.mat, sig.level = 0.01, insig = "blank",
diag = FALSE) ```
[1]: https://i.stack.imgur.com/xkKLY.png
[2]: https://i.stack.imgur.com/jrghy.png
[3]: https://i.stack.imgur.com/DHUEe.png


