Two dataframes join

Hello,

How is possible to join two 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

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

Getting this output?

Or any example?

Thanks!!

Your R code does not correspond to the tables in the Google doc. The second data frame has incorrect names. This is the correct form:

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),
                  group = c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2),
                  product = 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))

Now you can simply rbind both data frames:

DF <- rbind(DF1, DF2)

   id group product frecuency
1   1     1      11         2
2   1     1      22         2
3   1     1      33         2
4   1     2      44         3
5   1     2      55         3
6   1     3      66         3
7   1     3      77         4
8   1     3      88         4
9   1     4      99         4
10  1     4    1010         5
11                           
12                           
13                           
14                           
15                           
16  2     5    1111         6
17  2     5    1212         7
18  2     5    1313         7
19  2     7    1414         3
20  2     8    1515         2
21  1     1    1111         2
22  1     1    1212         2
23  1     1    1313         2
24  1     1    1414         2
25  1     1    1515         2
26  1     1    1616         2
27  1     1    1717         4
28  1     1    1818         4
29  1     1    1919         4
30  1     1    2020         5
31  2     2    2121         2
32  2     2    2222         2
33  2     2    2323         3
34  2     2    2424         4
35  2     2    2525         5
36  2     2    2626         4
37  2     2    2727         4
38  2     2    2828         4
39  2     2    2929         3
40  2     2    3030         2

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.