I am actually running econometrics analysis. I encounter problem in this analysis. I am using Rstudio.
My Database is composed of 1408 (704 for type 1 and 704 for type 2) observations and 49 variables.
Gender    Period   Matching group   Group  Type  Overcharging
1           1            73            1       1    NA
0           2            73            1       1    NA
1           1            77            2       1    NA
1           2            77            2       1    NA
...        ...          ...           ...     ...   ...
0           1            73            1       2    1
0           2            73            1       2    0
1           1            77            2       2    0
1           2            77            2       2    1
...        ...          ...           ...     ...   ...
You can see that NA values are correlated with type of the agent (if agent is type 1). What I'd like to do is : if agents of type 1 belong to the same matching group, group and period of agents type 2, then replace NA by the same value of the agent of the type 2 (for each row).
Expected output     
Gender    Period   Matching group   Group  Type  Overcharging
1           1            73            1       1    1
0           2            73            1       1    0
1           1            77            2       1    0
1           2            77            2       1    1
0           1            73            1       2    1
0           2            73            1       2    0
1           1            77            2       2    0
1           2            77            2       2    1
 
     
     
    