[R] choosing items from array: very stupid and simple question

2012-01-08 Thread Philipp Chapkovski
x-1:11 y-2:3 is there a way to do something like x[x==y] (which actually produce error)? I am really got stuck __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] choosing items from array: very stupid and simple question

2012-01-08 Thread Sarah Goslee
x[x %in% y] [1] 2 3 2012/1/8 Philipp Chapkovski chapkov...@gmail.com: x-1:11 y-2:3 is there a way to do something like x[x==y] (which actually produce error)? I am really got stuck -- Sarah Goslee http://www.functionaldiversity.org __

Re: [R] choosing items from array: very stupid and simple question

2012-01-08 Thread Richard M. Heiberger
This does literally what you asked for x[x %in% y] [1] 2 3 This is more likely what you want which(x %in% y) [1] 2 3 It is an artifact of this example that the two results look the same. Here is a different example that distinguishes them, and in this example, %in% is probably not right