I am trying to bind together the two following vectors:
library(dplyr)
library(mvtnorm)
x.points <- seq(-3, 3, length.out = 100)
y.points <- seq(-3, 3, length.out = 100)
I can do it easily in base R:
data1 <- cbind(x.points, y.points)
head(data1)
#> x.points y.points
#> [1,] -3.000000 -3.000000
#> [2,] -2.939394 -2.939394
#> [3,] -2.878788 -2.878788
#> [4,] -2.818182 -2.818182
#> [5,] -2.757576 -2.757576
#> [6,] -2.696970 -2.696970
I have tried using dplyr following the suggestion in this answer but it did not work that well:
data2 <- bind_cols(x.points, y.points, c("x","y"))
#> Error: Can't recycle `..1` (size 100) to match `..3` (size 2).
I am confused about the difference between setting up "inner names" and "outer names" mentioned in the answer linked above: "Rows require inner names like c(col1 = 1, col2 = 2)
, while columns require outer names: col1 = c(1, 2)
."
Created on 2021-04-08 by the reprex package (v0.3.0)