R: repeat elements of a list based on another list
问题 I have searched for this but in vain. the problem is I have two lists, first with the elements to be repeated for example my.list<-list(c('a','b','c','d'), c('g','h')) and the second list is the number of times each element is to be repeated repeat.list<-list(c(5,7,6,1), c(2,3)) I would like to create a new list in which each element in my.list is repeated based in repeat.list i.e. result: [[1]] [1] "a" "a" "a" "a" "a" "b" "b" "b" "b" "b" "b" "b" "c" "c" "c" "c" "c" "c" "d" [[2]] [1] "g" "g"