Skip to content
Prev 200554 / 398503 Next

Add "bin" variable to dataframe

Hi All - I am trying to add a new variable to my dataframe which is a series
of bins based on another variable which is distance. So, I'd like to end
with each of my distances classified into bin 1, bin 2, bin 3 etc. 

Below is a start.

x<-rnorm(100, mean=100, sd=30) #Generates sample distances
breaks = seq(0, 200, l = 11) #Generates 10 bins of equal distance (i.e.
20km)

Any ideas? 

Best, 

Gunadi