Each element of a vector is duplicated by the R function rep():
Reply with "c("A","B"), times=2"
[1] "A" "B" "A" "B"
This is comparable to Python's list multiplication:
>>> ["A","B"]
*2
['A', 'B', 'A', 'B']
However, it is also feasible to specify the number of repetitions for each element of the vector using the rep() R function:
Reply with "c("A","B", times=c(2,3)"
[1] "A" "A" "B" "B" "B"
Is a function like that available in Python? How else could it be defined? By the way, I'm also curious about a method that duplicates an array's rows.