如何在R中的另一个向量元素中按次重复向量元素?
我想重复每一次如何在R中的另一个向量元素中按次重复向量元素?,r,R,我想重复每一次 repeat.it <- c(0, 3951982, 7635488, 10986941) 我试过的代码: rep(repeat.it,each=repeat.times)但这似乎给了我错误的结果。我怎样才能做好呢?差不多了: rep(repeat.it, times = repeat.times) # [1] 0 0 3951982 3951982 3951982 7635488 7635488 # [8] 7635488
repeat.it <- c(0, 3951982, 7635488, 10986941)
我试过的代码:
rep(repeat.it,each=repeat.times)
但这似乎给了我错误的结果。我怎样才能做好呢?差不多了:
rep(repeat.it, times = repeat.times)
# [1] 0 0 3951982 3951982 3951982 7635488 7635488
# [8] 7635488 7635488 10986941 10986941
差不多了:
rep(repeat.it, times = repeat.times)
# [1] 0 0 3951982 3951982 3951982 7635488 7635488
# [8] 7635488 7635488 10986941 10986941
这是一个选择
res <- mapply(rep, repeat.it, repeat.times)
res <- unlist(res)
res这是一个选项
res <- mapply(rep, repeat.it, repeat.times)
res <- unlist(res)
res@MAPK,它回答了你的问题吗?@MAPK,它回答了你的问题吗?