Suppose I have a dataframe with 10 rows and 5 columns like this
df <- data.frame(matrix(rep(1:10, 5), ncol=5))
I want to split the dataframe into a list with 5 vectors of unequal length, where first vector begins with the first row of column one, second vector begins with the second row of column two, and so on. I will provide the index where each of the vectors shall end. For example, if this index vector is c(3, 5, 4, 8, 10)
then I expect the list to be list(1:3, 2:5, 3:4, 4:8, 5:10)
. Thanks!