paste函数(用于字符串的连接等)
(1)两个元素进行连接
> paste("aa","bb",sep=",")
[1] "aa,bb"
paste("A",1:6,sep="")
[1] "A1" "A2" "A3" "A4" "A5" "A6"
(2)连接后变为一个字符串而不是多个元素(使用collapse参数)
a<-c("I1","I2","I7")
> a
[1] "I1" "I2" "I7"
> paste(a,collapse = ",")
[1] "I1,I2,I7"
(3)paste和cat区别
a<-1:3
> b<-4:6
> c<-c("ha","haha")
> paste(a,b,c)
[1] "1 4 ha" "2 5 haha" "3 6 ha"
> cat(a,b,c)
1 2 3 4 5 6 ha haha