I have a dataframe containing two columns. One is for a number, the other one is for a Label
Example
1 200 A
2 300 B
3 350 C
4 2000 A
5 2200 D
6 2300 K
I want basically to segment this dataframe and to transform the second column into a vector containing words in the condition that the difference betweem any two values on the first column is < 1000
Expected Result is
C("ABC","ADK")
Example here we will have a vector C having ABC and ADK as words because the difference between row4 and row3 > 1000
Any idea on how to do it without consuming a lot of computing ?
Edited based on your clarification
RESULTS: