I am looking to integrate data from one dataframe (A) selectively into another (B). The conditions are as follows: The data frames share two columns (miRNA & Gene). Dataframe A also contains column with a value for the pair.
I want to create a new column in dataframe B that is taken from the Value column in A and contains a value if the pair (same miRNA & Gene from a row in A) matches in B. If a pair does not match in B, create a new row with the score.
#Initialize column in B that will house A value if first two columns match B$A_Values <- 0 If A[,1:2] == B[,1:2]: Change initialized B$A_Value to A[VALUE] of row from A[,1:2] If A[,1,2] is not in B[,1:2]: Add row in B[,1:2] Change initialized B$A_Value to A[Value] of row from A[,1:2]
The dataframes are not of equal length and there will be items in B not found in A, though I assume my initialization will default value them to 0. Any help will be appreciated.