1

I have multiple character strings, let's say 'pred_1', 'pred_2' and 'pred_3'. Now I want to get a list with all pairs of the strings. So, the resulting list should contain 'pred_1 pred_2', 'pred_1 pred_3' and 'pred_2 pred_3'. Does anyone know how to automate this for more than three character strings?

baqm
  • 121
  • 6

1 Answers1

4

An option is combn

combn(v1, 2, simplify = FALSE)

data

v1 <- paste0("pred_", 1:3)
akrun
  • 874,273
  • 37
  • 540
  • 662