Let's say I have a vector of strings:
vec <- c("D", "A", "B", "A")
I would like to insert a modified string (concatenate "_2" at the end of the strings) immediately after the original string, without sorting.
Expected output:
[1] "D" "D_2" "A" "A_2" "B" "B_2" "A" "A_2"
I am looking for solutions simpler than the one I shared below, which I think could be unnecessarily over-complicated.