I have derived all the start and stop positions within a DNA string and now I would like to map each start position with each stop position, both of which are vectors and then use these positions to extract corresponding sub strings from the DNA string sequence. But I am unable to efficiently loop through both vectors to achieve this, especially as they are not of the same length.
I have tried different versions of loops (for, ifelse) but I am not quite able to wrap my head around a solution yet.
Here is an example of one of my several attempts at solve this problem.
new = data.frame()
for (i in start_pos){
for (j in stop_pos){
while (j>i){
new[j,1]=i
new[j,2]=j
}
}
}
Here is an example of my desired result: start = c(1,5,7, 9, 15) stop = c(4, 13, 20, 30, 40, 50). My desired result would ideally be a dataframe of two columns mapping each start to its stop position. I only want to add rows on to df where by start values are greater than its corresponding stop values (multiple start values can have same stop values as long as it fulfills this criteria)as shown in my example below.
i.e first row df= (1,4)
second row df= (5,13)
third row df = (7, 13 )
fourth row df = (9,13)
fifth row df = (15, 20)