Assuming that the name of your data frame is df
, do the following:
split(df, findInterval(df$Depth..m., floor(min(df$Depth..m.)):0))
You will then get a list where each element is a data frame containing the rows that have Depth..m.
within a particular 1 m interval.
Notice however that empty bins will be removed. If you want to keep them you can use cut
instead of findInterval
. The reason is that findInterval
returns an integer vector, making it impossible for split
to know what the set of valid bins is. It only knows the values it has seen and discards the rest. cut
on the other hand returns a factor, which has all valid bins defined as levels.