用r中的=连接两个向量



我想用=符号连接两个向量,这样结果将是:"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和矢量ab

来实现。
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"

相关内容

  • 没有找到相关文章

最新更新