31

Say I have two character vectors:

a <- c("a", "b", "c")
b <- c("1", "2", "3")

How do I merge them such that I get:

ab <- c("a1", "b2", "c3")
2
  • 1
    @codoremifa: that's not at all the same question! Commented Dec 4, 2013 at 20:05
  • A bit of googling would have gotten you paste. The linked question tells you enough about the function to be able to use it for your problem. Commented Dec 4, 2013 at 20:12

1 Answer 1

44

You can use paste or paste0:

> a <- c("a", "b", "c")
> b <- c("1", "2", "3")
> paste0(a, b)
[1] "a1" "b2" "c3"
> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.