Is there an easy way to determine if one vector is nested within another? In other words, in the example below, each value of bar is associated with one and only one value of foo, so bar is nested within foo.
data.frame(foo=rep(seq(4), each=4), bar=rep(seq(8), each=2))
To clarify, here is the desired result:
foo <- rep(seq(4), each=4)
bar <- rep(seq(8), each=2)
qux <- rep(seq(8), times=2)
# using a fake operator for illustration:
bar %is_nested_in% foo # should return TRUE
qux %is_nested_in% foo # should return FALSE