6

I have 2 vectors, x and y:

x <- seq(from=21.6, to=22, by=0.01)
y <- seq(from=58.77, to=58.93, by=0.01)

I want to create a data frame df1<-data.frame(x,y) with all the possible combinations of x and y. How can I do this?

Ignacio
  • 7,646
  • 16
  • 60
  • 113

1 Answers1

14

We can use expand.grid to get all the possible combinations between the two vectors.

expand.grid(x,y)
akrun
  • 874,273
  • 37
  • 540
  • 662