OneBite.Dev - Coding blog in a bite size

combine two strings in R

Code snippet on how to combine two strings in R

x <- "Hello"
y <- "World"
z <- paste(x, y)

This code example creates three strings, x, y, and z. The first two strings, x and y, are assigned the values ‘Hello’ and ‘World’. The third string, z, is created by ‘combining’ the first two strings with the paste() function. The paste() function takes arguments, which are the two strings to be combined, and returns a single string which combines them. In this example, the two strings ‘Hello’ and ‘World’ are combined to create the single string ‘Hello World’, which is assigned to string z.

r