Im trying to categorising my data into different group based on type of data. My data and code is as follow:
bank ROE bank1 0.73 bank2 0.94 bank3 0.62 b
You could also try:
lst1 <- list(sob, fob, jov) test$type <- setNames(rep(seq_along(lst1),sapply(lst1,length)),unlist(lst1))[test$bank] test$type[is.na(test$type) ] <- 4 test$type #[1] 1 1 1 2 2 2 3 3 3 3 3 4