consider 2 dataframes:
p1 <- data.frame(x1 = c(5,8), y1=c(3,8)); p2 <- data.frame(x1 = c(2,10), y1=c(5,3))
I want to compare each value of p1 respectively to the value of p2 (same position), I tried:
ifelse( p1 < p2, p2 - p1, ifelse(p1 > p2, p1 + p2, 1))
I want have result: data.frame(x1 = c(7,2), y1=c(2,11))
but it seems ifelse work only on vectors and it returns a list.
do you have an idea?