Based on the description, if we need unique values an if condition is sufficient i.e. loop over the sequence of 'dep' column if the element is not (!) %in% 'v', append that element to 'v' and update the 'v' by assignment (<-)
v <- vector()
for(i in seq_along(a$dep)) {if(!a$dep[i] %in% v) v <- c(v, a$dep[i])}
As ifelse requires all arguments to be of same length, 'v' is dynamic in length as we concatenate elements to it, thus, the 'yes', 'no' (always length 1 -a$dep[i]) mismatches in length.
One option with ifelse would be to initiate a vector 'v' with the same length as the 'dep' column length, then use ifelse to check whether the 'dep' element is %in% the whole vector (return TRUE/FALSE - length 1), then return blank (yes - "" - length 1) or else return the element of 'dep (no - a$dep[i]- length 1)
v <- character(nrow(a))
for(i in seq_along(a$dep)) v[i] <- ifelse(a$dep[i] %in% v, "", a$dep[i])
and then remove the blank elements
v[v != ""]
#[1] "a" "b" "c" "e"
The ifelse is useful as vectorized function and its use would not be optimal here
data
a <- data.frame(dep = c('a', 'b', 'a', 'c', 'e', 'a'))