我正在处理多个二进制和连续变量,并希望确定它们之间的潜在相关性 . 我已经尝试使用R中的'corrplot'包来计算描述这种关系的相关矩阵但是仍然得到以下错误“cor(Zamcor)中的错误:'x'必须是数字]” .

代码如下(带有示例数据框):

# Create the variables
PriceHa <- c(25,60,30,9)
Ecoregion1 <- c('1','0','0','1')
GMA <- c('1','0','0','1')
FarmSize <- c(30,40,50,60)
Area <- c(1,0.5,3,4)

#Make the data frame
Zamcor <- data.frame(PriceHa, Ecoregion1, GMA, FarmSize, Area)

# Group correlation test 
corr.test(Zamcor)

# Simple visualisation of correlation analysis effect size including significance    
x <- cor(Zamcor)
cor(x,use="pairwise.complete.obs")
colnames (x) <- c("Price/ha", "Ecoregion 1","GMA", "Farm size", "Area")
rownames(x) <- c("Price/ha", "Ecoregion 1", "GMA", "Farm size", "Area")
p.mat <- cor.mtest(Zamcor, conf.level = .95)
p.mat <- cor.mtest(Zamcor)$p
corrplot(x, p.mat = p.mat, sig.level = .05)

我被告知使用point-biserial correlation因为它可以处理二进制和连续变量 . 但是,它似乎有no advantage to using that over the corr.test function . 但是当我使用corr.test时它不起作用"Error in cor(x, use = use, method = method) : 'x' must be numeric" .

我的问题 - 哪个函数最适合用于我的二进制和分类变量,这仍然使我能够绘制相关矩阵而不违反相关性测试的假设?