使用c()和有append()什么区别?有没有?
> c(      rep(0,5), rep(3,2) )
[1] 0 0 0 0 0 3 3
> append( rep(0,5), rep(3,2) )
[1] 0 0 0 0 0 3 3
Aru*_*run 42
你使用它的方式并没有显示c和之间的区别append.append在某种意义上它允许在某个位置之后将值插入向量中.
例:
x <- c(10,8,20)
c(x, 6) # always adds to the end
# [1] 10 8 20 6
append(x, 6, after = 2)
# [1] 10  8  6 20
如果您输入appendR终端,您将看到它用于c()附加值.
# append function
function (x, values, after = length(x)) 
{
    lengx <- length(x)
    if (!after) 
        c(values, x)
    # by default after = length(x) which just calls a c(x, values)
    else if (after >= lengx) 
        c(x, values)
    else c(x[1L:after], values, x[(after + 1L):lengx])
}
您可以看到(注释部分)默认情况下(如果您未after=在示例中设置),它只返回c(x, values).c是一个更通用的函数,可以将值连接到vectors或lists.