I am trying to manipulate column data in a two column matrix and output it as a data.frame.
The matrix that I have is in this format where both the values in the sta
An ugly dplyr solution:
dplyr
library(dplyr) df <- as.data.frame(df) df %>% mutate(End = V2[findInterval(V1, na.omit(V2)) + 1]) %>% group_by(End) %>% summarise(Start = paste(V1, collapse=", "))
Edit - using findInterval thanks to @bgoldst