标签: r count duplicates return
所以我有一列用于变量,一列用于计数。
vars <- c("a","b","c","d","e") counts <- c(1,3,2,3,0)
我想返回的列表/向量
"a" "b" "b" "b" "c" "c" "d" "d" "d"
有什么提示吗?
答案 0 :(得分:1)
使用rep
rep
rep(vars, times = counts) #[1] "a" "b" "b" "b" "c" "c" "d" "d" "d"