[BioC] How to do a Vlookup-type function using a value range

Harris A. Jaffee hj at jhu.edu
Tue May 6 22:46:35 CEST 2014


If X and Y are your data frames, the rows you want are given by

	library(IRanges) 

	nearest(IRanges(X[,"Position"], width=1), IRanges(start=Y[,"Start"], end=Y[,"Stop"]))



On May 6, 2014, at 3:34 PM, Elena Sorokin wrote:

> I have two data frames as input:
> 
>> small  Position
> 1        6
> 2       14
> 3        1
> 
> 
>> lookup_table  Start Stop Value
> 1     1    5     a
> 2     6   10     b
> 3    11   15     c
> 
> And I want the following output:
> 
>> outcome  Position Value
> 1        6     b
> 2       14     c
> 3        1     a
> 
> What is some R code that I can write to accomplish this task?
> 
> Thank you,
> 
> Elena
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor



More information about the Bioconductor mailing list