I have the following vector:
vector1 <- c("A", "B", "C" , NA, NA, "D")
I want to apply this function paste ignoring NA values in vector1
vector2 <- paste("#", vector1, "something", sep = "")
and obtain this
vector2 <- c("#Asomething", "#Bsomething" , "#Csomething", NA, NA, "#Dsomething")
I want to avoid ex-post solutions using sub where I just get rid of elements containing the letters "NA" in the string.
I saw a similar question: suppress NAs in paste() however there they want to ignore NA and simply paste #something whereas I want NA to be displayed.