I will merge the below two df's in ascending order by time, non-duplicating. My goal is to also have two new variables.
df1
   time   freq                  
1   1.5    1
2   3.5    1
3   4.5    2
4   5.5    1
5   8.5    2
6   9.5    1
7  10.5    1
8  11.5    1
9  15.5    1
10 16.5    1
11 18.5    1
12 23.5    1
13 26.5    1
df2
  time freq
1  0.5    6
2  2.5    2
3  3.5    1
4  6.5    1
5 15.5    1
Please help me with the code for creating the two new columns:
- Where if the - freqvalue corresponds to a- timein- df1, then a new variable (- var1) would record the associated- freqvalue, AND- 0if no such- timevalue exists for df1.
- Where if the - freqvalue corresponds to a- timein- df2, then a second new variable (- var2) would record that- freqvalue from- df2, AND- 0if no such- timevalue exists for- df2.
So I would have a table like this below:
time var1 var2
0.5   0    6
1.5   1    0
2.5   0    2
3.5   1    1
4.5   2    0
5.5   1    0
...
 
     
     
     
    