我想用=符号连接两个向量,这样结果将是:"a"="z","b"="y","c"="x">
a<-c("a","b","c")
b<-c("z","y","x")
c<-rbind(a,b)
假设您想要的输出如下
c("a"="z","b"="y","c"="x")
#> a b c
#> "z" "y" "x"
这可以用setNames
和矢量a
和b
a<-c("a","b","c")
b<-c("z","y","x")
setNames(b, a)
#> a b c
#> "z" "y" "x"
您也可以使用names<-
即
names(b) <- a
b
# a b c
#"z" "y" "x"
a<-c("a","b","c")
b<-c("z","y","x")
c <- paste0(a, "=", b)
c
[1] "a=z" "b=y" "c=x"