Sorry if this is a silly question. What does asymmetric refer to from ?intersect, and are there any aspects of the result that may be different from expected (reason for exclamation point) ? As toy data, if needed, here are the examples from the help page. (x <- c(sort(sample(1:20, 9)),NA)) (y <- c(sort(sample(3:23, 7)),NA)) Thanks, Juliet
davidr at rhotrading.com
2009-Jan-13 15:56 UTC
[R] meaning of asymmetric on help page for intersect
There is also a symmetric set difference = union(setdiff(x, y), setdiff(y, x)) denoted x \Delta y -- David -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Juliet Hannah Sent: Tuesday, January 13, 2009 9:41 AM To: r-help at r-project.org Subject: [R] meaning of asymmetric on help page for intersect Sorry if this is a silly question. What does asymmetric refer to from ?intersect, and are there any aspects of the result that may be different from expected (reason for exclamation point) ? As toy data, if needed, here are the examples from the help page. (x <- c(sort(sample(1:20, 9)),NA)) (y <- c(sort(sample(3:23, 7)),NA)) Thanks, Juliet ______________________________________________ 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.
On 1/13/2009 10:41 AM, Juliet Hannah wrote:> Sorry if this is a silly question. What does asymmetric refer to from > ?intersect, and are there any > aspects of the result that may be different from expected (reason for > exclamation point) ?There are two definitions for a set difference: the symmetric one and the asymmetric one. R uses the asymmetric one, so setdiff(A, B) is the intersection of A with the complement of B. (The complement is taken in the union of A and B). The symmetric difference is described on the Wikipedia page http://en.wikipedia.org/wiki/Symmetric_difference. In R, you could get it as union(setdiff(A, B), setdiff(B, A)) Duncan Murdoch> > As toy data, if needed, here are the examples from the help page. > > (x <- c(sort(sample(1:20, 9)),NA)) > (y <- c(sort(sample(3:23, 7)),NA)) > > Thanks, > > Juliet > > ______________________________________________ > 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.
Carlos J. Gil Bellosta
2009-Jan-13 16:04 UTC
[R] meaning of asymmetric on help page for intersect
Hello, The symmetric set difference of A and B is the set of elements in A or B but not in A intersection B, i.e., ( (A U B) \ (A intersection B) ). The asymmetric set difference of A and B is the set of elements of A except those in B, i.e., (A \ B). Best regards, Carlos J. Gil Bellosta http://www.datanalytics.com
Prof Brian Ripley
2009-Jan-13 16:19 UTC
[R] meaning of asymmetric on help page for intersect
Because there is also a symmetric difference: see http://en.wikipedia.org/wiki/Symmetric_difference> Sorry if this is a silly question. What does asymmetric refer to from > ?intersect, and are there any > aspects of the result that may be different from expected (reason for > exclamation point) ? > > As toy data, if needed, here are the examples from the help page. > > (x <- c(sort(sample(1:20, 9)),NA)) > (y <- c(sort(sample(3:23, 7)),NA)) > > Thanks, > > Juliet-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Christos Hatzis
2009-Jan-13 16:45 UTC
[R] meaning of asymmetric on help page for intersect
... which is the same as setdiff(union(x, y), intersect(x, y)) -Christos> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of > davidr at rhotrading.com > Sent: Tuesday, January 13, 2009 10:56 AM > To: Juliet Hannah; r-help at r-project.org > Subject: Re: [R] meaning of asymmetric on help page for intersect > > There is also a symmetric set difference = union(setdiff(x, > y), setdiff(y, x)) denoted x \Delta y > > -- David > > > -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] > On Behalf Of Juliet Hannah > Sent: Tuesday, January 13, 2009 9:41 AM > To: r-help at r-project.org > Subject: [R] meaning of asymmetric on help page for intersect > > Sorry if this is a silly question. What does asymmetric refer > to from ?intersect, and are there any aspects of the result > that may be different from expected (reason for exclamation point) ? > > As toy data, if needed, here are the examples from the help page. > > (x <- c(sort(sample(1:20, 9)),NA)) > (y <- c(sort(sample(3:23, 7)),NA)) > > Thanks, > > Juliet > > ______________________________________________ > 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. > > ______________________________________________ > 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. > >