R语言 连接两个字符串 – paste()方法

R语言 连接两个字符串 – paste()方法

R编程中的 paste() 方法用于通过分隔符来连接两个字符串的值。

语法: 粘贴(string1, string2, sep=)

返回: 返回串联后的字符串。

例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"

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程