【问题标题】:Insert (push) multiple elements at multiple different positions at the same time [duplicate]同时在多个不同位置插入(推送)多个元素[重复]
【发布时间】:2017-12-10 22:56:42
【问题描述】:

我喜欢 R 中的 append 函数:

L <- 1:4
append(L,5,3)
[1] 1 2 3 5 4

我想知道是否有一个像append 一样工作但允许在多个位置同时插入多个元素的函数?

L <- 1:100
elements <- letters[1:5]
positions <- c(17,28,50,65,80)

类似:

append(L, elements, positions)

【问题讨论】:

  • 谢谢,绝对是重复的。那里有很棒的答案

标签: r append


【解决方案1】:

我想这就是你想要的:Add a series of elements in different locations within a vector

我认为不存在像 append(L, elements, positions) 这样的函数,尽管它会很酷。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-30
    • 2020-05-12
    • 1970-01-01
    • 1970-01-01
    • 2014-10-24
    • 2016-06-26
    • 2011-12-31
    • 1970-01-01
    相关资源
    最近更新 更多