I have the following data frame:
Id Value Freq
1 A 8 2
2 B 7 3
3 C 2 4
and I want to obtain a new data frame by replicating each Value
according to Freq
:
Id Value
1 A 8
2 A 8
3 B 7
4 B 7
5 B 7
6 C 2
7 C 2
8 C 2
9 C 2
I understand this can be very easily done with purrr
(I have identified map_dfr
as the most suitable function), but I cannot understand what is the best and most "compact" way to do it.