我想interElem
在每 2 个列表元素之后交错。
数据:
listi <- c(rbind(letters[1:4], list(c(13,37))))
interElem <- c("inter","leavistan")
好像:
> listi
[[1]]
[1] "a"
[[2]]
[1] 13 37
[[3]]
[1] "b"
[[4]]
[1] 13 37
[[5]]
[1] "c"
[[6]]
[1] 13 37
[[7]]
[1] "d"
[[8]]
[1] 13 37
>
期望的结果(列表元素编号不准确)
> listi
[[1]]
[1] "a"
[[2]]
[1] 13 37
[[XXX]]
[1] "inter" "leavistan"
[[3]]
[1] "b"
[[4]]
[1] 13 37
[[XXX]]
[1] "inter" "leavistan"
[[5]]
[1] "c"
[[6]]
[1] 13 37
[[XXX]]
[1] "inter" "leavistan"
[[7]]
[1] "d"
[[8]]
[1] 13 37
>