I have created the following data set
p_cd = c(0.01, 0.15, 0.30, 0.50, 0.70, 0.80, 0.90, 0.99)
p_bm = c(0.01, 0.15, 0.30, 0.50, 0.70, 0.80, 0.90, 0.99)
data = as.data.frame(expand.grid(p_cd,p_bm))
data = cbind(data,rep(NA,dim(data)[1]))
weights = c(NA,0.48,0.28,0.1,0.03,0.02,0.013,0.01,NA,NA,1.52,0.57,0.18,0.1,0.07,0.07,NA,NA,NA,1.8,0.57,0.35,0.25,0.24,NA,NA,NA,NA,2.21,1.26,0.91,0.86,NA,NA,NA,NA,NA,3.62,2.62,2.5,NA,NA,NA,NA,NA,NA,5.25,4,NA,NA,NA,NA,NA,NA,NA,24.46,rep(NA,8))
u = 1
for(i in 1:dim(data)[1]){
if(data[i,1]>data[i,2]){
data[i,3] = weights[u]
u = u + 1
}
}
Based on that data set I create the following plot in ggplot2 in R
p_1 = ggplot() +
geom_point(data = subset(data), aes(x=p_cd, y=p_bm, col = weights), size = 3) +
scale_color_continuous(type = "viridis") +
geom_point(data = subset(data, weights <= 1), aes(x=p_cd, y=p_bm), color = "black", size = 3) +
xlim(0, 1) + ylim(0,1) +
ggtitle("N = 50 & K = 2") + labs(colour = "Root Mean Square Error")
However my goal is to plot only the points that are under the diagonal, i.e. all the points (the color points this this case) for which we have that data[i,1]>data[i,2]. How is this possible to be done in R?