Re: [R] complex search between dataframes

2011-06-02 Thread Remko Duursma
Here is another solution, using apply() and lapply(). # list of sequences corresponding to each row in data1: seqlist <- apply(data1, 1, function(x)seq(from=x[1], to=x[2])) # Find which rows of data2 are inside those sequences: rowsInSeq<- unlist(lapply(seqlist , function(x)which(data2$position

Re: [R] complex search between dataframes

2011-06-02 Thread Marc Schwartz
On Jun 2, 2011, at 1:42 PM, Filippo Beleggia wrote: > Hi! > > I am very new to R, I hope someone can help me. > > I have two dataframes: > > data1<-data.frame(from=c(1,12,16,40,55,81,101),to=c(10,13,23,45,67,99,123)) > data2<-data.frame(name=c(1,2,3,4,5,6,7,8,9),position=c(2,14,20,50,150,2000,2

[R] complex search between dataframes

2011-06-02 Thread Filippo Beleggia
Hi! I am very new to R, I hope someone can help me. I have two dataframes: data1<-data.frame(from=c(1,12,16,40,55,81,101),to=c(10,13,23,45,67,99,123)) data2<-data.frame(name=c(1,2,3,4,5,6,7,8,9),position=c(2,14,20,50,150,2000,2001,2002,85)) I want to know which of the entries in "position" of