I have two character vectors with the different set of names and values:
x <- c("a", "b", "c", "d", "e")
names(x) <- c("foo", "bar", "baz", "qux", "grault")
y <- c("c", "a", "d", "b")
names(y) <- c("bar", "foo", "qux", "corge")
Is there a way to compare x and y so that we know their values corresponding to the name bar are different because here x.bar = "b" and y.bar = "c"? Please note the names are not ordered. I tried setdiff and which(x != y) but neither one gives me the correct answer. Thanks!
You could do this: