[r] Call apply-like function on each row of dataframe with multiple arguments from each row