Hi all, I'm trying to find something like the "==" operator that will work on vectors or something equivalent to SQL's "IN" function. For e.g., if I have:
x <- c(1,2,3,4,5) y <- c("apples", "oranges", "grapes", "bananas", "pears") z <- data.frame (x,y) w <- c(2,4,5) I want R to return the values "oranges", "bananas", "pears" through some function like this: z$y[z$x == w] or in sql speak, like this z$y[z$x IN w] To complicate matters, my x variable is a date variable (as is w). Essentially, I have a bunch of dates with associated values and I want to retrieve all the associated values for particular dates. Is there any R function that will do this in a one-line, non-messy way? Thanks very much for any help! Emily _________________________________________________________________ [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.