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
  • 87
  • 4

1 Answers1

3

An option is combn

combn(v1, 2, simplify = FALSE)

data

v1 <- paste0("pred_", 1:3)
akrun
  • 789,025
  • 32
  • 460
  • 575