繁体   English   中英

如何使用double类型绘制Spearman相关性

[英]How to plot a Spearman correlation with type double

我试图绘制两个高度相关的变量之间的Spearman相关性,但我得到一个类型“双”错误。

错误 - 当试图在两个变量之间使用spearman相关时,不能强制'pairlist'对象输入'double'

我已经对数据进行了子集化,将两列转换为数值数据并尝试将数据帧转换为矩阵但我仍然得到相同的错误。

   library(ggpubr)
var_sub_set <- as.data.frame(bc_data[ ,c("compactness_mean", "points_mean" )])


Var <- as.data.frame(sapply(var_sub_set, as.numeric))

ggscatter(Var, x = "compactness_mean", y = "points_mean", 
          add = "reg.line", conf.int = TRUE, 
          cor.coef = TRUE, cor.method = "spearman",
          xlab = "Compactness Mean", ylab = "Points Mean")

数据应绘制在散点图上,并显示p_value和任何线性线。

dput sample output

structure(list(compactness_mean = c(0.06981, 0.1147, 0.07804, 
0.1136, 0.06934, 0.07722, 0.1021, 0.1768, 0.08578, 0.09097, 0.1644, 
0.06679, 0.1089, 0.03789, 0.09871, 0.133, 0.09462, 0.07664, 0.1838, 
0.01781, 0.04304, 0.02749, 0.01867, 0.01471, 0.08543, 0.0444, 
0.02068, 0.1562, 0.02069, 0.063, 0.02583, 0.0226, 0.05598, 0.01692, 
0.01737, 0.034, 0.0287, 0.02037, 0.03263, 0.06495, 0.1255)), .Names = c("compactness_mean", 
"points_mean"), row.names = c(NA, -569L), class = "data.frame")

代码是正确的。 重新安装ggp​​lot2和ggpubr解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM