#Hello friends,
#Please, about this simple DF:
DF1 <- data.frame(id = c(1,1,1,1,1,1,1,1,1,1, "", "", "", "", "",
2,2,2,2,2),
group = c(1,1,1,2,2,3,3,3,4,4,"", "", "", "", "",
5,5,5,7,8),
product = c(11, 22, 33, 44,55,66,77,88,99,1010, "", "", "", "", "",
1111, 1212, 1313, 1414, 1515),
frecuency = c(2,2,2,3,3,3,4,4,4,5,"","","","","", 6,7,7,3,2))
DF1
#How it is possible to insert this continuous data by ID like?
DF2 <- data.frame(id = c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2),
k = c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2),
group = c(1111,1212,1313,1414,1515,1616,1717, 1818, 1919,2020, 2121, 2222,2323, 2424, 2525, 2626, 2727, 2828, 2929, 3030),
frecuency = c(2,2,2,2,2,2,4,4,4,5,2,2,3,4,5,4,4,4,3,2))
DF2
#Obtaining this output or like this? by descending frequency
id group product frecuency
1 4 1010 5
1 3 77 4
1 3 88 4
1 4 99 4
1 2 44 3
1 2 55 3
1 3 66 3
1 1 11 2
1 1 22 2
1 1 33 2
1 1 2020 5
1 1 1717 4
1 1 1818 4
1 1 1919 4
1 1 1111 2
1 1 1212 2
1 1 1313 2
1 1 1414 2
1 1 1515 2
1 1 1616 2
2 5 1212 7
2 5 1313 7
2 5 1111 6
2 7 1414 3
2 8 1515 2
2 2 2525 5
2 2 2424 4
2 2 2626 4
2 2 2727 4
2 2 2828 4
2 2 2929 3
2 2 2323 3
2 2 2121 2
2 2 2222 2
2 2 3030 2
#Equal or similar merge or join, priorizing the group and frequency
#Thank you very much!!
Here is a spreadsheet maybe can help. SPREADSHEET
Equal or similar output
Thanks!!