Ваш фрейм данных:
df = structure(list(X1 = c("001", "001", "001", "002", "002", "002",
"002", "003", "003"), X2 = structure(c(3L, 2L, 1L, 6L, 4L, 5L,
3L, 1L, 3L), .Label = c("MLB", "MLS", "NBA", "NFL", "NHL", "UFC"
), class = "factor")), row.names = c(NA, -9L), class = "data.frame")
Чтобы стать уникальным для всех X2 с X1 в 001 002 003:
unique(df$X2[df$X1 %in% c("001","002","003")])
[1] NBA MLS MLB UFC NFL NHL
Чтобы получить уникальный X2 в X1s:
unique(df[df$X1 %in% c("001","002","003"),])
X1 X2
1 001 NBA
2 001 MLS
3 001 MLB
4 002 UFC
5 002 NFL
6 002 NHL
7 002 NBA
8 003 MLB
9 003 NBA