The following reproducible example creates a conditional density plot depicting change by aspect. I've included NoData in the example because my original dataset also has 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)
Related Questions:
just to show what @Roland said in the comments, you use the function in a wrong manner.
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)
and now h contains the conditional density functions over the levels of aspect.
str(h)
List of 4
$ E :function (v)
$ N :function (v)
$ S :function (v)
$ SW:function (v)
eg
h$E(-Inf)
[1] 0.21875
h$E(Inf)
[1] 0.25
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.