Say that I have these dataframes:
SNPs <- c('SNP1', 'SNP2', 'SNP3', 'SNP4', 'SNP5', 'SNP6')
Basepair <- c('75', '251', '643', '820', '952', '1455')
df <- data.frame(SNPs, Basepair)
BP_start <- c('0', '100', '200', '300', '400', '500', '600', '700', '800', '900', '1000', '1100', '1200', '1300', '1400', '1500', '1600')
BP_end <- c('100', '200', '300', '400', '500', '600', '700', '800', '900', '1000', '1100', '1200', '1300', '1400', '1500', '1600', '1700')
sweep_nr <- c(1:17)
df_sweep <- data.frame(BP_start, BP_end, sweep_nr)
And I want to merge the df_sweep dataframe with the df dataframe, so that there is a new column showing what sweep_nr the SNP is included in.
Then, they'd have to merge based on ranges, since for example SNP1 is between BP_start == 0 and BP_end == 100, but I haven't found any way to do this kind of merge.