Say I have two character vectors:
a <- c("a", "b", "c") b <- c("1", "2", "3")
How do I merge them such that I get:
ab <- c("a1", "b2", "c3")
Concatenation operator || In addition to the CONCAT() function, Oracle also provides you with the concatenation operator ( || ) that allows you to concatenate two or more strings in a more readable fashion: string1 || string2 || string3 || ...
In formal language theory and computer programming, string concatenation is the operation of joining character strings end-to-end. For example, the concatenation of "snow" and "ball" is "snowball".
The concatenation of vectors can be done by using combination function c. For example, if we have three vectors x, y, z then the concatenation of these vectors can be done as c(x,y,z). Also, we can concatenate different types of vectors at the same time using the same same function.
You can use paste
or paste0
:
> a <- c("a", "b", "c") > b <- c("1", "2", "3") > paste0(a, b) [1] "a1" "b2" "c3" >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With