0

Is it correct to do the intervals?

20-35k-35-50k-50-70k-70k+

my_data$Löneutfall <- ifelse(my_data$Löneutfall<=20000,1, 
ifelse(my_data$Löneutfall>=20001 & my_data$Löneutfall<=35000,2, 
ifelse(my_data$Löneutfall<35000,3, ifelse(my_data$Löneutfall>=35000, 4, 
ifelse(my_data$Löneutfall<50000,5, ifelse(my_data$Löneutfall<60000,7, 
ifelse(my_data$Löneutfall<70000,8, ifelse(my_data$Löneutfall<70000 +, 9)))) 
Phil
  • 7,287
  • 3
  • 36
  • 66
  • I might check out other posts such as [this one](https://stackoverflow.com/questions/39123458/how-does-cut-with-breaks-work-in-r) that use the `cut` function and see if this will give you what you are looking for. – Ben Dec 28 '21 at 22:31
  • You could also use ifelse statements like you are trying to create intervals. However, you have to make clear what are the intervals you want to obtain. Is it: < 20k | 20k-35k | 35k-50k | 50k-75k | >75k ? (This are only 5 classes, but you are using 9 in your ifelse statement.) – JKupzig Dec 29 '21 at 10:37
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jan 06 '22 at 13:15

0 Answers0