1

I have the following problem: I have a big dataframe with this format:

enter image description here

Each of these measurements represents a whole cell with the name that contains the ":" regular expression, the ones that follow are area measurements of points inside a cell with their respective areas.

I would like to subset this into multiple dataframes containing just the part that ranges from the name with ":" to the next one. In this example it would be from row 1 to 14 and then from 15 to the next before the regular expression with ":".

Phil
  • 7,287
  • 3
  • 36
  • 66
  • It would help a lot if you can share part of the dataset instead of just the picture. You can get some good advice on how to help us help you if you look here: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – itsMeInMiami Aug 29 '20 at 20:20
  • 2
    Thank you! this is my first question. – Felipe Del Valle Aug 29 '20 at 20:25

1 Answers1

2

We could use split to split the dataset into a list of data.frame by creating a grouping index with grepl and cumsum. Here, the first list element includes rows from 1 to 14, next from 15 to the row before the next :, ...

lst1 <- split(df1, cumsum(grepl(":", df1$Label)))
akrun
  • 874,273
  • 37
  • 540
  • 662