Maybe you can try
> A %>% add_column(as_tibble(matrix(rnorm(4), 2, 2)))
# A tibble: 2 x 4
x y V1 V2
<dbl> <dbl> <dbl> <dbl>
1 -1 -2 -0.647 -0.982
2 1 2 -0.264 -1.25
If you want to add columns with names starting with z
, we can use
A %>% add_column(setNames(as_tibble(matrix(rnorm(4), 2, 2)),paste0("z",1:2)))
or (thank akrun's comment)
A %>% add_column(as_tibble(matrix(rnorm(4), 2, 2, dimnames = list(NULL, c('z1', 'z2')))))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…