以下可重现的示例创建了conditional density plot描述方面的更改。我在示例中包含NoData,因为我的原始数据集也有NoData。
aspect = c("N", "N", "E", "S", "SW", "SW", "E", "W", "N", "N")
change = c(-1, NA, 1, NA, 1, 1, -1, 1, -1, NA)
mydata = data.frame(aspect,change)
x = factor(mydata$change)
cdplot(x~mydata$aspect)
相关问题:
答案 0 :(得分:1)
只是为了展示@Roland在评论中所说的内容,你以错误的方式使用该功能。
aspect = c("N", "N", "E", "S", "SW", "SW", "E", "W", "N", "N")
change = sample(rep(c(-1,1,NA), each = 100),100,replace=T)
mydata = data.frame(aspect,change,stringsAsFactors=T)
str(mydata)
'data.frame': 100 obs. of 2 variables:
$aspect: Factor
$change: num
h <- cdplot(aspect~change, data = mydata)
现在h包含方面级别的条件密度函数。
str(h)
List of 4
$ E :function (v)
$ N :function (v)
$ S :function (v)
$ SW:function (v)
e.g
h$E(-Inf)
[1] 0.21875
h$E(Inf)
[1] 0.25