I want to subtract y from x, which means deleting one โAโ, three โBโ and one โEโ from x, so it xNewwill c("A", "C", "A","B","D"). It also means
length(xNew)=length(x) - length(y)
x <- c("A","A","C","A","B","B","B","B","D","E")
y <- c("A","B","B","B","E")
setdiff does not work because
xNew <- setdiff(x,y)
xNew
[1] "C" "D"
also does not work
xNew <- x[-match(y,x)]
xNew
[1] "A" "C" "A" "B" "B" "B" "D"
He deletes โBโ in fifth position 3 times, so there are three more โBsโ left.
Does anyone know how to do this, is there a function available in R, or should we write a private function? Thank you very much in advance.