Switching "yes" and "no" in a vector for "1" and "2"



I have a long vector containing nothing but 'yes' or 'no'; I want to code it into 1s and 2s. Please could someone show me how to do it? I've tried using switch and ifelse, but failed.
(Ultimately I want to use the vector in the pch field of my funnel chart, to show two types of points.)

Many thanks!!!!


vector_yes_no <- c("yes", "no", "no", "yes", "no")
#>  chr [1:5] "yes" "no" "no" "yes" "no"

vector_12 <- ifelse(vector_yes_no == "yes", 1, 2)
#>  num [1:5] 1 2 2 1 2


Amazing thanks so much!!!!