我在ifelse这里有一个棘手的任务。下面是我的代码显示两个时期(future和current)的数据。数据mean, 5th and 95th在 xy 坐标旁边具有置信界限。我想比较两个 dfs (和) 的mean, 5th and 95th置信界限 (CI )。futurecurrent
条件:
1) 如果CIsforfuture不与currentfutrue 重叠,且 CI 高于当前,则pch=2.
2) 如果CIsfor与 futruefuture不重叠,current且 CI 低于当前,则pch=3.
3) 如果未来的 CI 与当前的 CI 重叠,则pch=4
library(raster)
library(rasterVis)
s <- stack(replicate(2, raster(matrix(runif(100), 3))))
current <- data.frame(coordinates(sampleRandom(s, 3, sp=TRUE)),
C5th=c(17.643981,16.83572,9.979904),
CMean=c(26.66364,19.74286,15.10000),C95th=c(35.68329,22.64999,20.22010))
future <- data.frame(coordinates(sampleRandom(s, 3, sp=TRUE)),
C5th=c(17.643981,16.83572,9.979904)*2,
CMean=c(26.66364,19.74286,15.10000)*2,C95th=c(35.68329,22.64999,20.22010)*2)
然后将上述三个的结果conditions添加到我的地图中。类似的东西(只是一个尝试):
levelplot(s, margin=FALSE, at=seq(0, 1, 0.05)) +
layer(sp.points(xy, pch=ifelse(condition, 2, 3,4), cex=2, col=1), columns=1) +
layer(sp.points(xy, pch=ifelse(condition, 2, 3,4), cex=2, col=1), columns=2)
例如,在下图中,如果 NFC 的最小值(future)完全高于 AFC 的最大值(current),则条件 1。如果 NFC 的最大值完全低于 AFC 的最小值,则条件 1。如图所示下面满足条件3。

请帮忙。在。