What I want to do is match two dataframes by rownames. Not all the rownames are the same, when they not match R should give a NA in the n column. When the rownames match I want to calculate a ratio (b / a) in the n column. Does anyone have any tips on how to do this?
Here a example:
a <- c
name1 1
name2 2
name3 3
name4 5
b <- d
name1 1
name2 6
name4 10
Final result
ab <- c d n
name1 1 1 1
name2 2 6 3
name3 3 NA NA
name4 5 10 2