-3

I have a list of variables with two sets of identifying numbers. I just used paste to get the vectors, so I have :

in <- "abc001":"abc050"

and

out <- "001xyz":"200xyz"

I want to combine them so that every value is accounted for. I tried paste(in, "-", out, separate="") which gives:

"abc001-001xyz"

But only until I hit 200xyz. How can I get a list of every possible combination of those values?

Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
thejuanald
  • 27
  • 5

1 Answers1

0

Use expand.grid:

df <- expand.grid(in, out)
paste(df$in,df$out, separate = "-")
yeedle
  • 4,918
  • 1
  • 22
  • 22