[R] Performing multiplication on duplicate values

JDINIS jorgemdinis at gmail.com
Mon Oct 29 17:27:19 CET 2012


Hello all,  thank you for your help. The task I need to perform is difficult
to explain so I apologize a head of time for any confusion.

I have a data frame with these colnames() Reference_Position,
Reference_Allele, Variant_Allele, Variant_Frequency,   AAC_Variant. If a
value is duplicated in the "Reference_Position" column, I would both of
their "Variant_Frequency" values multiplied and inserted into a new data
frame.

example below: reference position 64 is repeated,  multiple 94.155381 by
92.947658 and insert value into "Value".

Because I do not know how to best explain this or phrase it into a logical
questions, here is a before and after. Also, if you could explain the code a
bit, that would be appreciated as well- teach and person to fish!


Before

 >dat
[Reference_Position] [Reference_Allele] [Variant_Allele] [Variant_Frequency]  
[AAC_Variant]
                   16                G              A         91.833811  
Val6Met,Met
                   52                G              A         93.969466     
Val18Ile
                   64                G              T         94.155381     
Val22Phe
                   73                C              A         94.293478     
Gln25Lys
                 131                G              A         94.268168     
Arg44Lys
                 64                  G              A         92.947658     
Ser48Asn
After

 >dat
[Reference_Position]    [Variant_Frequency]       [Value]
                   16                91.833811                            
NA
                   52                93.969466                            
NA
                   64                94.155381                        
85.152215
                   73                94.293478                           NA
                 131                94.268168                           NA
                   64                92.947658                        
85.152215




--
View this message in context: http://r.789695.n4.nabble.com/Performing-multiplication-on-duplicate-values-tp4647772.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list