To append a string to another string in R, you can use the paste
function.
In this example,
str1
with a value of "Hello"
.paste
function to append the string " World"
to str1
.paste
function concatenates the two strings and returns the result.str1 <- "Hello"
concatenated <- paste(str1, "World")
cat(concatenated)
Hello World
In this example,
str2
with a value of "banana"
.paste
function to append the string "apple"
to str2
.paste
function concatenates the two strings and returns the result.str2 <- "banana"
concatenated <- paste(str2, "apple")
cat(concatenated)
bananaapple
In this tutorial, we learned How to Append a String to another String in R language with well detailed examples.