peter dalgaard
2018-Oct-25 14:13 UTC
[R] "logical indexing, " [was] match() question or needle haystack problem for a data.frame
> On 25 Oct 2018, at 16:06 , Knut Krueger <rhelp at krueger-family.de> wrote: > > Hi Bert, > another question for indexing > 1. is there a good manual for indexing?Extract is at least authoritative....> > 2. is it possible to get !%in% > f.eYes: x[!(x$A %in% y$B),] -pd> x =data.frame("A"=c(1:5),"C"=c("A","B","C","D","E")) > y =data.frame("B"=c(1,3,5)) > test = x[x$A %in% y$B,] > test = x[x$A %in% y$B,] > > test > A C > 1 1 A > 3 3 C > 5 5 E > > > means: the result where I am looking for is: > test > A C > 2 2 B > 4 4 D > > no problem with a loop but in a short way I do not find a solution > > Kind Regards Knut > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
Knut Krueger
2018-Oct-26 06:28 UTC
[R] "logical indexing, " [was] match() question or needle haystack problem for a data.frame
Am 25.10.18 um 16:13 schrieb peter dalgaard:> > > Yes: x[!(x$A %in% y$B),]Ok thats in my opinion a little workaround why?: There is an = and !< and > means the opposite is available between terms. why is there f.e no %!in%, %notin% or !%in% This would be more intuitive. Kind regards Knut
David Winsemius
2018-Oct-28 16:58 UTC
[R] "logical indexing, " [was] match() question or needle haystack problem for a data.frame
> On Oct 25, 2018, at 11:28 PM, Knut Krueger <rhelp at krueger-family.de> wrote: > > Am 25.10.18 um 16:13 schrieb peter dalgaard: >> >> Yes: x[!(x$A %in% y$B),] > > Ok thats in my opinion a little workaround > why?: > > There is an > = and !> < and > > > > means the opposite is available between terms. > > why is there f.e no %!in%, %notin% or !%in% > > This would be more intuitive.This illustrates a failure to read the obvious help page completely. The "Examples" section includes a definition of "%w/o%" which is exactly what was desired. -- David.> > Kind regards Knut > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
MacQueen, Don
2018-Oct-29 16:13 UTC
[R] "logical indexing, " [was] match() question or needle haystack problem for a data.frame
Wrong comparisons, I think. The opposite of A & B is !(A & B) There is no single operator that can replace the "&" in A & B that gives the "opposite" -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 Lab cell 925-724-7509 ?On 10/25/18, 11:28 PM, "R-help on behalf of Knut Krueger" <r-help-bounces at r-project.org on behalf of rhelp at krueger-family.de> wrote: Am 25.10.18 um 16:13 schrieb peter dalgaard: > > > Yes: x[!(x$A %in% y$B),] Ok thats in my opinion a little workaround why?: There is an = and ! < and > means the opposite is available between terms. why is there f.e no %!in%, %notin% or !%in% This would be more intuitive. Kind regards Knut ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.