0

I want to join two vectors with the = symbol, so that the result will be: "a"="z","b"="y","c"="x"

a<-c("a","b","c")
b<-c("z","y","x")
c<-rbind(a,b)
Johan
  • 109
  • 5

3 Answers3

3

Assuming your desired output is as follows

c("a"="z","b"="y","c"="x")
#>   a   b   c 
#> "z" "y" "x"

this can be achieved using setNames with vectors a and b

a<-c("a","b","c")
b<-c("z","y","x")

setNames(b, a)
#>   a   b   c 
#> "z" "y" "x"
nniloc
  • 4,128
  • 2
  • 11
  • 22
1

You may also use names<- i.e

names(b) <- a
b

# a   b   c 
#"z" "y" "x" 
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
0
a<-c("a","b","c")
b<-c("z","y","x")

c <- paste0(a, "=", b)
c

[1] "a=z" "b=y" "c=x"
denisafonin
  • 1,116
  • 1
  • 7
  • 16