[R] Multiply Two Dataframes

From: Bert Jacobs <bert.jacobs_at_figurestofacts.be>
Date: Mon, 07 Jun 2010 20:29:15 +0200

   

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_at_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. Received on Mon 07 Jun 2010 - 18:29:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 Jun 2010 - 19:10:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive