Search code examples
rvariablesdistanceproximity

Dummy variable for distance interval


In my dataset I want to create dummy variables for identifying the influence of a variable within certain distances.

The distances should be:

0-100 meters

100-200 meters

200-300 meters

up to 1000 meters so all in all 10 dummy variables.

How do I do this

Thank you in advance

EDIT:

When I run a regression with the dummy variables, I can't get the interval 0-100 meters in the regression. It's left out. Any ideas on why?

Thanks in advance


Solution

  • Are you looking for cut function:

    x <- 1:1000
    cut(x,c(min(x),100,200,300,max(x)))
    

    EDIT

    To get the 10 levels :

    cut(x,seq(min(x),max(x),100))