【发布时间】:2020-10-02 23:38:56
【问题描述】:
[![在此处输入图像描述][1]][1]我有一个数据集,其中癌症和潜在风险因素(例如,agefirstchild)的值为 Yes No。下面是一个数据集的例子
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)
我想运行一个 Spearman 相关图,如下所示[![在此处输入图像描述][2]][2]
此图来自 corrplot 包。但是当我将此代码应用于我的数据集时,它给了我一个错误。 矩阵错误(if (is.null(value)) logical() else value, nrow = nr, dimnames = list(rn, : 'dimnames' [3] 的长度不等于数组范围 图片可在代码下的链接和描述下方找到:
[![Corrplot][2]][2]
[![以下示例中的相关图][3]][3]
我可以在代码的什么地方添加方法,我需要 Spearman?它不一定需要与下面完全相同,但格式和图中的值相似
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
【问题讨论】:
标签: r