Hi,

I have the following two dataframes (Df1 and Df2):

Df1 has a layout like

 

ID Location  Var1 Var2 Var3 . Var20

A  Loc2          1       1        1    .       1

A  Loc1          0       1        0    .       1

B  Loc1          0       0        0    .       0       

A  Loc3          1       0        1    .       0

C  Loc3          1       0        1    .       0

B  Loc2          0       0        0    .       1       

D .

..

 

 

Df2 has a layout like

ID Var1 Var2 Var3 ..  Var20

A   0.2     0.3    0.2   ....   0.15

B   0.1     0.1     0.1  .    0.1   

C    0        0       0     .   0.50

D .

.

 

And I like to have the following result

ID Location  Var1  Var2   Var3 .    Var20

A  Loc2          0.2     0.3      0.2   .     0.15

A  Loc1          0        0.3      0      .     0.15

B  Loc1          0        0         0      .     0       

A  Loc3          0.2     0        0.2   .      0

C  Loc3          0       0        0      .       0

B  Loc2          0       0        0      .       0.1       

D .

..

 

Is this easy doable in R? I've tried to figure it out with mapply but
without result.

Thanks for helping me out.

Bert

 

 


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to