sqldf merging with subset in specific range
Is this what you want:
m <- read.table(text = "10
+ 15 + 36 + 37 + 38 + 44 + 45 + 57 + 61 + 62 + 69 ")
n <- read.table(text = "30 38
+ 52 62 ")
require(sqldf)
sqldf("select m.V1
+ from m, n + where m.V1 between n.V1 and n.V2 + ") V1 1 36 2 37 3 38 4 57 5 61 6 62
On Wed, Dec 26, 2012 at 7:00 PM, Matthew Liebers <mrl86 at cornell.edu> wrote:
Hi all:
I have two data sets. Set A includes a long list of hits in a single
column, say:
m$V1
10
15
36
37
38
44
45
57
61
62
69 ...and so on
Set B includes just a few key ranges set up by way of a minimum in column X
and a maximum in column Y. Say,
n$X n$Y
30 38 # range from 30 to 38
52 62 # range from 52 to 62
I would like the output to be the rows containing the following columns:
m$V1
36
37
38
57
61
62
I am interested in isolating the hits in data set A that correspond to any
of the "hotspot" ranges in data set B. I have downloaded sqldf and tried a
couple things but I cannot do a traditional merge since set B is based on a
range. I can always do a manual subset but I am trying to figure out if
there is anything more expedient since these df's will be quite large.
Thanks!
Matt
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.