0

Some variables were categorized via quantcut() in train_df and I want to apply same categories intervals to test_df without having to create ifelse conditions for every variable.

In the following example, I want to apply the interval from train_df$tenor_q to test_df$tenor

train_df <- train_df %>% mutate(tenor_q = quantcut(tenor,4))

attributes(train_df$tenor_q)
$levels
[1] "[6,36]"  "(36,48)" "48"      "(48,60]"

Thank you

lovalery
  • 4,254
  • 3
  • 13
  • 27
sungdo
  • 1
  • 1
  • 3
    Hi and welcome sungdo. Please have a look at: [How to make a great r reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Marco_CH Jan 08 '22 at 22:00

0 Answers0