0

Based on the table below, how would I be able to put "wedding" and "renewable_energy" which both occur less frequently, into the "other" category?

enter image description here

Feverish123
  • 105
  • 7

1 Answers1

1
loans$reason <- factor(ifelse(as.character(loans$reason) %in% c("wedding", "renewable_energy"), "other", loans$reason))

Your reason column is probably of type factor, hence it changed to numbers, so you need to convert to character first. And optionally, after that to factor again.

Lennyy
  • 5,754
  • 2
  • 8
  • 22