0

I have two list

list_1 <- list('A', 'B', 'C')

list_2 <- list('X', 'Y')

if I want the resultant list to be of the form

list_3 <- list('AX', 'AY', 'AZ', 'BX', 'BY', 'BZ', 'CX', 'CY', 'CZ')

The final list should be all possible combinations of the elements in both the lists without duplicates.

David
  • 8,113
  • 2
  • 17
  • 36
Ankit Daimary
  • 148
  • 1
  • 6

2 Answers2

1

You can do the following:

as.list(outer(list_1,list_2, paste0))

Information regarding outer

David
  • 8,113
  • 2
  • 17
  • 36
1

You can do:

do.call(paste0, expand.grid(list_1, list_2))
Clemsang
  • 5,053
  • 3
  • 23
  • 41