I would like to append data to my list if I only append a new data.
data <- c("A","B","C")
My function
x<- function(...){
data <- ifelse(... %in% data, append(data, ""),append(data, as.character(...)))
return(data)
}
If I want to append "D" my desire output is
data
[1] "A" "B" "C" "D"
But I got this
data
[1] "A"
>Solution :
x <- c("A","B","C")
y <- c("D", "A")
union(x, y)
# [1] "A" "B" "C" "D"