Hello, I have a dataset named 'week' that contains a variable named 'DIST'. The structure of it is like this :
ID DIST
1 35463
2 43264
3 43356
...
I want to allocate certain values for each data(rows) according to the sub range its 'DIST' variable belongs to. So I made a code like below. This was an initial code as well as a sample for question, with only 5 categories(sub ranges).
making_ordinal_category_distance = ifelse(week$DIST < 13057, "5",
ifelse(week$DIST >= 13057 & week$DIST < 34577, "4",
ifelse(week$DIST >= 34577 & week$DIST < 55039, "3",
ifelse(week$DIST >= 55039 & week$DIST < 79043, "2", "1"))))
This can't be used in respect to 100 categories, because would make the script very messy. And now I want to devide sub range(category) with quntile value, and made a list for quntile by 1% that I want to use for devision like below(I can transform this into anything if you tell me requirement for your solution, vector, dataframe, whatever).
quant = seq(from = 0.01, by = 0.01)
list_for_division = quantile(week$DIST, probs = quant)
But the problem is, I have no idea how to apply this. Do I have to use conditional like before? Or is there any package helps this kind of work? If former is right, how I can make code with visibility although I have to consider 100 number of cases?