如何在R中连接两个数组

Jos*_*ose 4 arrays r concatenation

我有两个数组。

使用numpy.append我们可以合并两个数组。

我们如何在 R 中做同样的事情?

merge不可以这样做。

Python 输出/示例:

   a=np.array([1,2,3,4,5,5])
   b=np.array([0,0,0,0,0,0])
   np.append(a,b)

   array([1, 2, 3, 4, 5, 5, 0, 0, 0, 0, 0, 0])   # this is what I want
Run Code Online (Sandbox Code Playgroud)

x<-c(mat , (0.0) * (l - length(demeaned)))

mat is matrix (size is 20)

l - length(demeaned)是 10

我想要最后30号的

asc*_*ter 8

-c函数连接其参数。向量可以是数字或其他向量的串联:

a = c(1,2,3,4,5,5)
b = c(0,0,0,0,0,0)
c(a,b)

 [1] 1 2 3 4 5 5 0 0 0 0 0 0
Run Code Online (Sandbox Code Playgroud)

至少对于像 python 示例这样的一维数组,这相当于np.append