Check column values are in different sets I have a data frame called data with lots of columns, and Country is one of them.

I created a new logical column called train, which is true when the row belongs to the train set and false otherwise.  The data frame is already sampled.

Now I want to be sure that there are no countries in both train and test sets with this code:

nrow( data[ data[ data$train, ]$Country %in% data[! data$train, ]$Country, ] ) == 0


which evaluates to true, so I guess I sampled correctly.  But that line makes my eyes bleed.
I would do:

with(data, length(intersect(Country[train], Country[!train])) == 0)