Hello,
I have a problem with de full_join command. I have two data frames for two rounds of an experiment. This is, in the first round, i have variables that start with r1_nameofvariable (and this is the first data frame), and in the second round i have the same variables that i have in the first dataframe, but they start with r2_nameofvariable.
I also have a variable that identifies de id of each person of the experiment (it is the same in both data frames).
I have to merge this 2 dataframes by de ID of each person. The result that I Want is:
id; r1_nameofvariable; r2_nameofvariable
Im using the full_join command, but the problem is that each observation (i.e each row of the dataframe from the first round) it is being duplicate when I use this command, when the only thing I want is to merge the columns using de ID variable (that is common for both dataframes).
An example:
I have the following dataframes:
Round 1:
#> ID. r1_candidate. r1_sex.
#> 1 A m
#> 2 B m
#> 3 C f
#> 4 D m
#> 5 E f
#> 6 F f
Round 2:
#> ID. r2_candidate. r2_sex.
#> 1 F m
#> 2 J f
#> 3 Z f
#> 4 Y m
#> 5 Q m
What i want is to merge both dataframe (using the ID). Like the following:
#> ID. r1_candidate. r1_sex. r2_candidate.r2_sex
#> 1 A m F m
#> 2 B m j f
#> 3 C f Z f
#> 4 D m Y m
#> 5 E f Q m
#> 6 F f NA NA
The problem is that when I use the following command:
round_join <- full_join(round_1, round_2, by="ID")
I get the result, but the obsevation (each row of each dataframe) duplicates and i don't know why.
Please someone help me.