Re: [R] intersection in data frame

2022-10-27 Thread Gábor Malomsoki
Dear all, i have tried all of your proposals, all of them was ok. Maybe dcast() with data table was faster. Thank you! Best regards Gabor Am Fr., 14. Okt. 2022 um 01:31 Uhr schrieb Dénes Tóth < toth.de...@kogentum.hu>: > Or if your data is really large, you can try data.table::dcast(). > > > l

Re: [R] intersection in data frame

2022-10-13 Thread Dénes Tóth
Or if your data is really large, you can try data.table::dcast(). > library(data.table) > dcast(ID ~ station, data = as.data.table(df1)) ID xy xz 1: 12 15 20 2: 13 16 19 (Note: instead of `as.data.table()`, you can use `setDT` or create your object as a data.table in the first place.) On

Re: [R] intersection in data frame

2022-10-13 Thread Rui Barradas
Hello, To reshape from long to wide format, here are two options: df1 <- 'IDstation value 12 xy15 12 xz20 13 xy 16 13 xz 19' df1 <- read.table(textConnection(df1), header = TRUE) # base R reshape(df1, direction = "wide", idvar = "ID", tim

Re: [R] intersection in data frame

2022-10-13 Thread Ben Tupper
Hi, If you are game to use a tidy approach then you can use tidyr::pivot_wider() library(dplyr) library(tidyr) x <- dplyr::tribble( ~ID, ~station, ~value, 12, "xy", 15, 12, "xz", 20, 13, "xy", 16, 13, "xz", 19) tidyr::pivot_wider(x, names_from = station,

[R] intersection in data frame

2022-10-13 Thread Gábor Malomsoki
Dears, i need to create from a column of observations variables in a datafram like this way: example: original: IDstation value 12 xy15 12 xz20 13 xy 16 13 xz 19 new df: ID xy xz 12 15 20 13 16 19 i have been loo

Re: [R] intersection of two polygons which are not shapefiles

2016-07-18 Thread S Ellison
> I have two sets of points for which I've already determined which ones points > for the boundaries with the chull function. What I need for what I'm doing is > the coordinates where the two resulting polygons overlap. There's a relevant answer on mathoverflow that might help if you're thinking

[R] intersection of two polygons which are not shapefiles

2016-07-18 Thread Adrienne Wootten
All, Greetings! I hope things are going well for all! I apologize if someone's already answered this and I'm just not finding it. Here's what I'd like to do, but I'm hitting a brick wall with it. I have two sets of points for which I've already determined which ones points for the boundaries wi

Re: [R] intersection between two matrices based on two columns in R

2015-09-09 Thread Jeff Newmiller
Ergh... DYAC. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research E

Re: [R] intersection between two matrices based on two columns in R

2015-09-09 Thread David Winsemius
On Sep 9, 2015, at 12:39 PM, Lida Zeighami wrote: > Hi there, > > I want to find the intersection between two different data frame or > matrices based on two columns. > for example in matrix A I have 5 columns, the first two columns are Id1 and > Id2 and I have the same columns in the other matr

Re: [R] intersection between two matrices based on two columns in R

2015-09-09 Thread Duncan Murdoch
On 09/09/2015 3:48 PM, Jeff Newmiller wrote: > Matrices and data frames are write different. For this you most likely want > to use days frames. ... > Sent from my phone. Please excuse my brevity. ... and your auto-correct. ;-) Duncan Murdoch __ R-h

Re: [R] intersection between two matrices based on two columns in R

2015-09-09 Thread Bert Gunter
I am not quite clear what you mean by "intersection", but I think ?merge is what you are looking for. Cheers, Bert P.S. Please post in plain text, not HTML (though here it didn't matter). Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom

Re: [R] intersection between two matrices based on two columns in R

2015-09-09 Thread Jeff Newmiller
Matrices and data frames are write different. For this you most likely want to use days frames. ?merge Using typical options merge gives you all columns from both data frames. You can choose to select specific columns by indexing the data frames before passing them to merge if you don't want t

[R] intersection between two matrices based on two columns in R

2015-09-09 Thread Lida Zeighami
Hi there, I want to find the intersection between two different data frame or matrices based on two columns. for example in matrix A I have 5 columns, the first two columns are Id1 and Id2 and I have the same columns in the other matrix B, (Id1, Id2 ,,,) how can I find the intersection between the

Re: [R] Intersection

2012-06-26 Thread arun
tes 1    15 2005-05-25 2    20 2005-06-25 3    25 2005-07-25 6    50 2005-10-25 I hope this is what you meant.  You mentioned the datasets have different dimensions.  Not sure what you meant. A.K. - Original Message - From: Васильченко Александр To: r-help@r-project.org Cc: Sent: Tuesd

Re: [R] Intersection

2012-06-26 Thread andrija djurovic
Hi. Try with following functions: ?intersection ?"%in%" ?"[" Perhaps someone will provide you more help if you read and follow posting guide http://www.R-project.org/posting-guide.html Andrija On Tue, Jun 26, 2012 at 5:03 PM, ÷ÁÓÉÌØÞÅÎËÏ áÌÅËÓÁÎÄÒ

Re: [R] Intersection

2012-06-26 Thread Sarah Goslee
That sounds like a job for merge(), but it's hard to be sure because you didn't provide the information requested in the posting guide. Sarah On Tue, Jun 26, 2012 at 11:03 AM, Васильченко Александр wrote: > Hello. > I have a problem with 2 dataframes. There are 2 columns - "value" and > "dates".

[R] Intersection

2012-06-26 Thread Васильченко Александр
Hello. I have a problem with 2 dataframes. There are 2 columns - "value" and "dates". These dataframes have different dimension. Some dates coincide. And I need to intersect them by dates and have on output two dataframes with identical columns "dates" and new dimension . "value" have to recieve in

Re: [R] Intersection of two chromosomal ranges

2012-03-04 Thread Martin Morgan
On 03/04/2012 11:06 AM, Yadav Sapkota wrote: Hi, I want to merge multiple chromosomal regions based on their common intersecting regions. I tried couple of things using while and if loops but did not work out. I would appreciate if anyone could provide me a small piece of code in R to get the i

[R] Intersection of two chromosomal ranges

2012-03-04 Thread Yadav Sapkota
Hi, I want to merge multiple chromosomal regions based on their common intersecting regions. I tried couple of things using while and if loops but did not work out. I would appreciate if anyone could provide me a small piece of code in R to get the intersection of following example: chr1: 100-15

Re: [R] Intersection of 2 matrices

2011-12-02 Thread jim holtman
Here is one way of doing it: >compMat2 <- function(A, B) { # rows of B present in A +B0 <- B[!duplicated(B), ] +na <- nrow(A); nb <- nrow(B0) +AB <- rbind(A, B0) +ab <- duplicated(AB)[(na+1):(na+nb)] +return(sum(ab)) +} > > >set.seed(8237) >

Re: [R] Intersection of 2 matrices

2011-12-02 Thread Hans W Borchers
Michael Kao gmail.com> writes: > Well, taking a second look, I'd say it depends on the exact formulation. In the applications I have in mind, I would like to count each occurrence in B only once. Perhaps the OP never thought about duplicates in B Hans Werner > > Here is an example based on t

Re: [R] Intersection of 2 matrices

2011-12-02 Thread Hans W Borchers
Michael Kao gmail.com> writes: > Your solution is fast, but not completely correct, because you are also counting possible duplicates within the second matrix. The 'refitted' function could look as follows: compMat2 <- function(A, B) { # rows of B present in A B0 <- B[!duplicated(

Re: [R] Intersection of 2 matrices

2011-12-02 Thread Michael Kao
On 2/12/2011 2:48 p.m., David Winsemius wrote: On Dec 2, 2011, at 4:20 AM, oluwole oyebamiji wrote: Hi all, I have matrix A of 67420 by 2 and another matrix B of 59199 by 2. I would like to find the number of rows of matrix B that I can find in matrix A (rows that are common to both matr

Re: [R] Intersection of 2 matrices

2011-12-02 Thread David Winsemius
On Dec 2, 2011, at 4:20 AM, oluwole oyebamiji wrote: Hi all, I have matrix A of 67420 by 2 and another matrix B of 59199 by 2. I would like to find the number of rows of matrix B that I can find in matrix A (rows that are common to both matrices with or without sorting). I have trie

[R] Intersection of 2 matrices

2011-12-02 Thread oluwole oyebamiji
Hi all,     I have matrix A of 67420 by 2 and another matrix B of 59199 by 2. I would like to find the number of rows of matrix B that I can find in matrix A (rows that are common to both matrices with or without sorting). I have tried the "intersection" and "is.element" functions in R but it on

Re: [R] Intersection between circle and line?

2011-09-27 Thread Chris82
Thanks! In principle it is a mathematical problem. I have already found some solutions with google. I thought there is maybe an existing R function or package which handel this stuff. But it seems not to be. sos package gives me no suitable information for that. With best regards -- View this

Re: [R] Intersection between circle and line?

2011-09-26 Thread David Winsemius
On Sep 26, 2011, at 11:03 AM, Chris82 wrote: Dear R users, I am thinking about an easy and especially fast solution to calculate the x,y coordinates of the interesection between the borders of the red circle and the line. This would seem to be the solution to two simultaneous equations :

[R] Intersection between circle and line?

2011-09-26 Thread Chris82
Dear R users, I am thinking about an easy and especially fast solution to calculate the x,y coordinates of the interesection between the borders of the red circle and the line. short example: plot(c(-3,0,3,9,21),c(-8,0,5,12,25)) draw.circle(0,0,radius=6,border="red",col=NA,lty=1,lwd=1) x <- c(-1

Re: [R] intersection on more than two sets

2010-06-03 Thread jim holtman
?Reduce > x <- function(z) Reduce('union', z) > x(list(1:3, 4:6)) [1] 1 2 3 4 5 6 > x(list(1:3, 4:6, 3:7)) [1] 1 2 3 4 5 6 7 > x <- function(z) Reduce('intersect', z) > x(list(1:3, 4:6, 3:7)) integer(0) > x(list(1:3, 2:6, 3:7)) [1] 3 On Thu, Jun 3, 2010 at 3:59 AM, amir wrote: > Hi, > > I want

[R] intersection on more than two sets

2010-06-03 Thread amir
Hi, I want to do an intersection or union on more than two sets. Is there any command to do this? Regards, Amir __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/

Re: [R] Intersection list

2010-05-06 Thread David Winsemius
On May 6, 2010, at 1:48 PM, Ralf B wrote: How can I create intersections of vectors? a <- c(1,2,3) b <- c(1,5,6) the intersected list c should contain c(1)... Is your help function not working? Ralf __ R-help@r-project.org mailing list https:/

Re: [R] Intersection list

2010-05-06 Thread Joris Meys
Check ?'%in%' > a[a %in% b] 1 On Thu, May 6, 2010 at 7:48 PM, Ralf B wrote: > How can I create intersections of vectors? > > a <- c(1,2,3) > b <- c(1,5,6) > > the intersected list c should contain c(1)... > > Ralf > > __ > R-help@r-project.org maili

Re: [R] Intersection list

2010-05-06 Thread John Ramey
?intersect -- John A. Ramey, M.S. Ph.D. Candidate Department of Statistics Baylor University On Thu, May 6, 2010 at 12:48 PM, Ralf B wrote: > How can I create intersections of vectors? > > a <- c(1,2,3) > b <- c(1,5,6) > > the intersected list c should contain c(1)... > > Ralf > > _

[R] Intersection list

2010-05-06 Thread Ralf B
How can I create intersections of vectors? a <- c(1,2,3) b <- c(1,5,6) the intersected list c should contain c(1)... Ralf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-p

Re: [R] Intersection for two curves

2010-04-25 Thread Carl Witthoft
> Many people seem to be reluctant to define functions, > even thought I think it is a pretty small step from > writing scripts to writing functions. I'm not so sure - I find most students struggle to grasp that next level of abstraction. Generalising from a specific task to a general function

Re: [R] Intersection for two curves

2010-04-24 Thread hadley wickham
> Many people seem to be reluctant to define functions, > even thought I think it is a pretty small step from > writing scripts to writing functions. I'm not so sure - I find most students struggle to grasp that next level of abstraction. Generalising from a specific task to a general function is

Re: [R] Intersection for two curves

2010-04-24 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Ehlers > Sent: Saturday, April 24, 2010 3:51 PM > To: hadley wickham > Cc: r-help@r-project.org > Subject: Re: [R] Intersection for two curves >

Re: [R] Intersection for two curves

2010-04-24 Thread Peter Ehlers
On 2010-04-24 13:50, hadley wickham wrote: On Sat, Apr 24, 2010 at 12:54 PM, Peter Ehlers wrote: Well, this has seriously gotten off the original topic. While Hadley makes some sense, it is nevertheless sometimes the case (surely so for David, I would surmise) that one is putting together a re

Re: [R] Intersection for two curves

2010-04-24 Thread Carl Witthoft
Well it sounds like you won't lose any work, but you will lose some time. But why not open another session of R for R-help questions? Then you're never in any danger. I often have four or five instances of R running for different projects. Hadley Well for one thing you turkey, OS X will no

Re: [R] Intersection for two curves

2010-04-24 Thread hadley wickham
On Sat, Apr 24, 2010 at 12:54 PM, Peter Ehlers wrote: > Well, this has seriously gotten off the original topic. > > While Hadley makes some sense, it is nevertheless > sometimes the case (surely so for David, I would surmise) > that one is putting together a response to an R-help > query when a ne

Re: [R] Intersection for two curves

2010-04-24 Thread Peter Ehlers
Well, this has seriously gotten off the original topic. While Hadley makes some sense, it is nevertheless sometimes the case (surely so for David, I would surmise) that one is putting together a response to an R-help query when a new query prompts one to temporarily abandon the first and formulat

Re: [R] Intersection for two curves

2010-04-24 Thread David Winsemius
On Apr 24, 2010, at 10:09 AM, hadley wickham wrote: Perhaps, true in some respects. I am still chiseling out work using primitive editing tools. But it still takes several minutes to load the objects I am working on into memory and then several minutes each to build new models. The models s

Re: [R] Intersection for two curves

2010-04-24 Thread hadley wickham
> Perhaps, true in some respects. I am still chiseling out work using > primitive editing tools. But it still takes several minutes to load the > objects I am working on into memory and then several minutes each to build > new models. The models still reside in memory, since I do not know any > met

Re: [R] Intersection for two curves

2010-04-24 Thread hadley wickham
>> If clearing out your workspace destroys *any* work, then something is >> seriously wrong with your workflow. >> > > Yes, of course.  Lets all post viruses to run on each others' > machines.  That will teach those users who don't run antivirus and > backup software between each posting to r-help.

Re: [R] Intersection for two curves

2010-04-24 Thread David Winsemius
On Apr 24, 2010, at 9:05 AM, hadley wickham wrote: rm(list=ls()) PLEASE, DON'T DO THAT. Or rather you can do it in your workspace but don't post it. It's not fair to a person who may not read your code line by line before pasting it into their workspace and having it wiped out. Do y

Re: [R] Intersection for two curves

2010-04-24 Thread Gabor Grothendieck
On Sat, Apr 24, 2010 at 9:05 AM, hadley wickham wrote: >>> rm(list=ls()) >> >> PLEASE, DON'T DO THAT. Or rather you can do it in your workspace but >> don't post it. It's not fair to a person who may not read your code line by >> line before pasting it into their workspace and having it wiped

Re: [R] Intersection for two curves

2010-04-24 Thread hadley wickham
>> rm(list=ls()) > > PLEASE, DON'T DO THAT. Or rather you can do it in your workspace but > don't post it. It's not fair to a person who may not read your code line by > line before pasting it into their workspace and having it wiped out. Do you > expect us to completely clear out our workspace

Re: [R] Intersection for two curves

2010-04-24 Thread David Winsemius
On Apr 24, 2010, at 8:10 AM, Muhammad Rahiz wrote: Thanks again David, I've made the changes. The optimize() function works alright but it does not give me the intersection. I suspect it must have to do with the user-defined function which I am totally clueless and am inexperienced with.

Re: [R] Intersection for two curves

2010-04-24 Thread Muhammad Rahiz
Thanks again David, I've made the changes. The optimize() function works alright but it does not give me the intersection. I suspect it must have to do with the user-defined function which I am totally clueless and am inexperienced with. Mind showing the way. Thanks again and thanks for your

Re: [R] Intersection for two curves

2010-04-23 Thread David Winsemius
On Apr 23, 2010, at 8:06 PM, Muhammad Rahiz wrote: Thanks David & Peter, The locator() works but not practical as I have to repeat the process many times. Does the code works on linear regression only? Should work for any process that can produce a function. When i tried to find the int

Re: [R] Intersection for two curves

2010-04-23 Thread Muhammad Rahiz
Thanks David & Peter, The locator() works but not practical as I have to repeat the process many times. Does the code works on linear regression only? When i tried to find the intersection at a non-linear curve, i get the following error Error in optimize(f = function(x) abs(xyf(ds) - n), c(

Re: [R] Intersection for two curves

2010-04-23 Thread Peter Ehlers
On 2010-04-23 11:46, David Winsemius wrote: On Apr 23, 2010, at 1:06 PM, Muhammad Rahiz wrote: Does anyone know of a method that I can get the intersection where the red and blue curves meet i.e. the value on the x-axis? x <- 1:10 y <- 10:1 plot(x,y) abline(lm(y~x),col="blue") abline(h=2.5,co

Re: [R] Intersection for two curves

2010-04-23 Thread David Winsemius
On Apr 23, 2010, at 1:06 PM, Muhammad Rahiz wrote: Does anyone know of a method that I can get the intersection where the red and blue curves meet i.e. the value on the x-axis? x <- 1:10 y <- 10:1 plot(x,y) abline(lm(y~x),col="blue") abline(h=2.5,col="red") Two ways : > xy <- lm(y~x) > xy

[R] Intersection for two curves

2010-04-23 Thread Muhammad Rahiz
Does anyone know of a method that I can get the intersection where the red and blue curves meet i.e. the value on the x-axis? x <- 1:10 y <- 10:1 plot(x,y) abline(lm(y~x),col="blue") abline(h=2.5,col="red") Muhammad __ R-help@r-project.org mailing li

Re: [R] Intersection an Sum between list and matrix

2009-10-22 Thread Romildo Martins
Sorry... example 2 was error! 2009/10/22 Romildo Martins > Hello, > > I need to do an intersection between the list elements (partitionslist) and > the columns and rows of a matrix (mm), so that the result will be the sums > of the rows and columns. > > > Thanks a lot, > > Romildo Martins > > Ex

[R] Intersection an Sum between list and matrix

2009-10-22 Thread Romildo Martins
Hello, I need to do an intersection between the list elements (partitionslist) and the columns and rows of a matrix (mm), so that the result will be the sums of the rows and columns. Thanks a lot, Romildo Martins Example 1.The Intersection and sum betweeen partitionslist[[1]][[2]] and mm is i

Re: [R] intersection of 2 density curves

2009-10-08 Thread Monica Pisica
-- > CC: pisican...@hotmail.com=3b r-h...@stat.math.ethz.ch > From: dwinsem...@comcast.net > To: r.m.k...@gmail.com > Subject: Re: [R] intersection of 2 density curves > Date: Thu=2C 8 Oct 2009 11:16:22 -0400 > > It should also be remembered that there will often be multiple >

Re: [R] intersection of 2 density curves

2009-10-08 Thread David Winsemius
It should also be remembered that there will often be multiple intersections of such density estimates. I hope this is not being done in support of a data-driven discretization of two group comparisons. Such practices are to be eschewed (as they are even worse than obfuscation). -- David

Re: [R] intersection of 2 density curves

2009-10-08 Thread Rainer M Krug
> ____ > > Date: Thu=2C 8 Oct 2009 16:01:36 +0200 > > Subject: Re: [R] intersection of 2 density curves > > From: r.m.k...@gmail.com > > To: pisican...@hotmail.com > > CC: r-h...@stat.math.ethz.ch > > > > > > > > On

Re: [R] intersection of 2 density curves

2009-10-08 Thread Monica Pisica
again=2C =20 Monica > Date: Thu=2C 8 Oct 2009 16:01:36 +0200 > Subject: Re: [R] intersection of 2 density curves > From: r.m.k...@gmail.com > To: pisican...@hotmail.com > CC: r-h...@stat.math.ethz.ch > > > > On Thu=2C Oct 8=2C 2009 at 3:48 PM=2C Monica P

Re: [R] intersection of 2 density curves

2009-10-08 Thread Rainer M Krug
On Thu, Oct 8, 2009 at 3:48 PM, Monica Pisica wrote: > > > Hi, > > I would like to find out the coordinates of the intersection points of 2 > density curves. I did a search but i didn't get any significant results. I > really hope some of you have some ideas. here it is an example: > > set.seed(12

[R] intersection of 2 density curves

2009-10-08 Thread Monica Pisica
Hi, I would like to find out the coordinates of the intersection points of 2 density curves. I did a search but i didn't get any significant results. I really hope some of you have some ideas. here it is an example: set.seed(123) x1 <- rnorm(100, 1, 1) x2 <- rnorm(100, 0, 1) d1 <- density(x

Re: [R] Intersection of two sets of intervals

2009-04-15 Thread William Dunlap
Inc - Spotfire Division wdunlap tibco.com ------- [R] Intersection of two sets of intervals Thomas Meyer tm35 at cornell.edu Wed Apr 15 16:52:48 CEST 2009 Previous message: [R] Intersection of two sets of intervals Next message: [R] Intersection of two se

Re: [R] Intersection of two sets of intervals

2009-04-15 Thread Thomas Meyer
a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Thomas Meyer Verzonden: woensdag 15 april 2009 14:59 Aan: r-help@r-project.org Onderwerp: [R] Intersection of two sets of

Re: [R] Intersection of two sets of intervals

2009-04-15 Thread jim holtman
he experiment died of. >>> ~ Sir Ronald Aylmer Fisher >>> >>> The plural of anecdote is not data. >>> ~ Roger Brinner >>> >>> The combination of some data and an aching desire for an answer does not >>> ensure that a reasonable answer

Re: [R] Intersection of two sets of intervals

2009-04-15 Thread Thomas Meyer
ey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Thomas Meyer Verzonden: woensdag 15 april 2009 14:59 Aan: r-help@r-project.org Onderwerp: [R] Intersection of two sets of intervals Hi, Algorithm question: I have two sets of "

Re: [R] Intersection of two sets of intervals

2009-04-15 Thread Thomas Meyer
t ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Thomas Meyer Verzonden: woensdag 15 april 2009 14:59 Aan: r-help@r-project.org Onderwerp: [R] Inte

Re: [R] Intersection of two sets of intervals

2009-04-15 Thread Stavros Macrakis
There is a very nice "intervals" package in CRAN. It is impressively efficient even for intersections of many millions of intervals. If I remember correctly, it is purely in-core, so on a 32-bit R you'll be limited to something like 100 million intervals. Is that enough for your application?

Re: [R] Intersection of two sets of intervals

2009-04-15 Thread ONKELINX, Thierry
.@r-project.org [mailto:r-help-boun...@r-project.org] Namens Thomas Meyer Verzonden: woensdag 15 april 2009 14:59 Aan: r-help@r-project.org Onderwerp: [R] Intersection of two sets of intervals Hi, Algorithm question: I have two sets of "intervals", where an interval is an ordered pair [a,b]

Re: [R] Intersection of two sets of intervals

2009-04-15 Thread Dimitris Rizopoulos
one way is: list1 <- as.data.frame(list(open=c(1,5), close=c(2,10))) list2 <- as.data.frame(list(open=c(1.5,3), close=c(2.5,10))) data.frame( open = pmax(list1$open, list2$open), close = pmin(list1$close, list2$close) ) I hope it helps. Best, Dimitris Thomas Meyer wrote: Hi, Algor

Re: [R] Intersection of two sets of intervals

2009-04-15 Thread Duncan Murdoch
On 4/15/2009 8:59 AM, Thomas Meyer wrote: Hi, Algorithm question: I have two sets of "intervals", where an interval is an ordered pair [a,b] of two numbers. Is there an efficient way in R to generate the intersection of two lists of same? For concreteness: I'm representing a set of intervals

[R] Intersection of two sets of intervals

2009-04-15 Thread Thomas Meyer
Hi, Algorithm question: I have two sets of "intervals", where an interval is an ordered pair [a,b] of two numbers. Is there an efficient way in R to generate the intersection of two lists of same? For concreteness: I'm representing a set of intervals with a data.frame: > list1 = as.data.fram

Re: [R] intersection of two matrices

2008-12-03 Thread bartjoosen
? merge complexkid wrote: > > Hi, > I have two matrices as follow: > matrix A = > > a=matrix(c(c("abc","abc","bcd","bcd","bce","bce"),c("a1","d2","d1","d2","a1","a2")),6,2) > > and matrix B which contains pair of values : > b=matrix(c(c("a1","a2"),c("a1","d2")),2,2) > > In short, I wish t

Re: [R] intersection of two matrices(updated)

2008-12-03 Thread jim holtman
Is this what you want: > a [,1] [,2] [1,] "abc" "a1" [2,] "abc" "d2" [3,] "bcd" "d1" [4,] "bcd" "d2" [5,] "bce" "a1" [6,] "bce" "a2" > b [,1] [,2] [1,] "a1" "a2" [2,] "a1" "d2" > x <- lapply(split(seq(nrow(a)), a[,1]), function(.indx){ + do.call(rbind, lapply(seq(nrow(b)), function(

[R] intersection of two matrices(updated)

2008-12-03 Thread T Joshi
Hi, I have two matrices as follow: matrix A = a=matrix(c(c("abc","abc","bcd","bcd","bce","bce"),c("a1","d2","d1","d2","a1","a2")),6,2) and matrix B which contains pair of values : b=matrix(c(c("a1","a1"),c("a2","d2")),2,2) In short, I wish to find out pairs of values in matrix a[,2] having s

[R] intersection of two matrices

2008-12-03 Thread T Joshi
Hi, I have two matrices as follow: matrix A = a=matrix(c(c("abc","abc","bcd","bcd","bce","bce"),c("a1","d2","d1","d2","a1","a2")),6,2) and matrix B which contains pair of values : b=matrix(c(c("a1","a2"),c("a1","d2")),2,2) In short, I wish to find out pairs of values in matrix a[,2] having sam