I have my dataframe set up like this:
set.seed(50)
m <- matrix(nrow=4,ncol=9)
m[1,] <- 0
for(i in 2:4){
for(j in 1:9){
m[i,j] <- m[i-1,j] + runif(1,max = .25)
}
}
df <- data.frame(pond=rep(c('A','B','C'),4,each = 3),
variable=(rep(c('most','least','random'),3)),
rank=rep(c(0,.1,.2,.3),each=9),
value= as.vector(t(m)))
I'd like to find the point at which these lines intersect with the line with equation y=0.5-x as shown in this plot:
I've had some success finding the coordinates of intersection using the solve command as outlined here. I'm not sure how to iterate this process over all the variables and ponds in the data frame, especially as the rank at which the line crosses varies between pond/variables.