[R] Putting x into the right subset

John Wiedenhoeft wiedenhoeft at gmx.net
Sat Jul 22 02:18:41 CEST 2006


Dear all,

I'm sorry I have to bother you with this newbie stuff.

Within a loop I obtain pairs of values x <- c(a, b). An empty set M is
defined before the loop (as a list or whatever). Now I want to do the
following: if there is a vector y in M  that contains at least one of
the values of x, then x shall be concatenated to y. If y doesn't contain
any of the values in x, then x shall be put into M as a new vector. I
first imagined it to be trivial but I'm having a hard time with the
if-statement. I tried to define a function contains(value, vector),
which returns FALSE or TRUE, but R complains that I tried to execute a
"non-function"...

Could anybody help a despaired newbie, please!

Thanks a lot,
John



More information about the R-help mailing list