To append a character to the end of a string in R, you can use the paste() function.
In this example,
str1
with a string value of "Hello World"
.'!'
to str1
.str1 <- "Hello World"
str1 <- paste(str1, '!')
print(str1)
Hello World!
In this example,
str2
with a string value of "How are you"
.'?'
to str2
.str2 <- "How are you"
str2 <- paste(str2, '?')
print(str2)
How are you?
In this tutorial, we learned How to Append a Character to end of a String in R language with well detailed examples.