How to pair rows in a data frame with many columns using dplyr in R?
问题 I have a dataframe containing multiple observations from the control and the experimental cohorts with replicates for each subject. Here is an example of my dataframe: subject cohort replicate val1 val2 A control 1 10 0.1 A control 2 15 0.3 A experim 1 40 0.7 A experim 2 45 0.9 B control 1 5 0.3 B experim 1 30 0.0 C control 1 50 0.5 C experim 1 NA 1.0 I'd like to pair each control observation with its corresponding experimental one for each value to calculate the ratio between the pairs. The