You are looking for the function setdiff
setdiff(vectorB$id, vectorA$id)
If you did not want this reduced to unique values, you could create a not in
function
(kudos to @joran here Match with negation)
'%nin%' <- Negate('%in%')
vectorB$id[vectorB$id %nin% vectorA$id]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…