在 R 编程中连接两个字符串 - paste() 方法
R 编程中的paste()
方法用于通过用分隔符分隔来连接两个字符串值。
Syntax: paste(string1, string2, sep=)
Return: Returns the concatenate string.
示例 1:
# R program to concatenate two strings
# Given Strings
string1 <- "Geeks"
string2 <- "Geeks"
# Using paste() method
answer <- paste(string1, string2, sep=" For ")
print(answer)
输出:
[1] "Geeks For Geeks"
示例 2:
# R program to concatenate two strings
# Given Strings
string1 <- "I Love"
string2 <- "R programming"
# Using paste() method
answer <- paste(string1, string2, sep=" ")
print(answer)
输出:
[1] "I Love R programming"