[R] "logical indexing, " [was] match() question or needle haystack problem for a data.frame

Knut Krueger rhe|p @end|ng |rom krueger-|@m||y@de
Thu Oct 25 16:06:52 CEST 2018


Hi Bert,
another question for indexing
1. is there a good manual  for indexing

2.  is it possible to get !%in%
f.e
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




More information about the R-help mailing list