我有大约17个土壤变量,我想将它们与海拔、温度和降雨量与物种丰富度和丰度进行相关性分析。我有39个地块(行(,列中包含环境变量,如海拔、丰度、物种丰富度、温度、降雨量,然后是土壤变量列表(17列(。下面是我的剧本。
我的脚本有问题吗?还是我使用的mac的笔记本电脑兼容性有问题?请帮忙。感谢
运行代码后,我得到了这个错误:
stop_if_high_cardinality(数据、列、基数阈值(出错:
"pH"列的水平(24(高于允许的阈值(15(。请删除该列或增加"基数阈值"参数。增加基数阈值可能会产生较长的处理时间
GGally::ggpairs(
na.omit(nfi_nontree_soilclim_data[, c(11:18)]),
upper = list(
continuous = wrap(
custom_ggally_cor,
method = "spearman", exact = FALSE,
size = 2.5, col = "black", family = "serif", digits = 2
), combo = "box_no_facet", discrete = "count", na = "na"
),
lower = list(
continuous = wrap(
ggally_smooth,
method = "loess", formula = y ~ x,
se = F, lwd = 3, col = "red", shrink = T
), combo = "facethist", discrete = "facetbar", na = "na"
),
diag = list(
continuous = wrap(
ggally_densityDiag,
col = "darkgrey", lwd = .1,
stat = "density", fill = "darkgrey"
), continuous = "densityDiag", na = "naDiag"
), axisLabels = c("show")
) + theme_bw() + theme(
text = element_text(family = "serif", size = 4),
axis.text = element_text(family = "serif", size = 4),
panel.grid = element_blank()
)```
此错误是内置的停止,因为默认参数设置为只允许在一个图中显示15个级别的变量。其中一个变量有24个级别,因此可以将参数(即基数阈值(调整为24,也可以将其设置为NULL。如果24的值不总是相同,则Null可能更具普遍性。但总的来说,同时描述的级别数量将被劝阻,并有这些停止限制。
library(GGally)
data(iris)
创建因子超过15级的数据
iris$group = as.factor(sample(sample(letters,16), 150, replace = TRUE))
只是证明任何一个条目都可以工作
ggpairs(iris, cardinality_threshold = 16)
ggpairs(iris, cardinality_threshold = NULL)