Reputation: 3369
I am trying to concatenate strings in pairs.
Here is what I am doing:
paste(c("C","S"), seq(1,5), sep="")
The result is:
C1, S2, C3, S4, C5
The result I want is:
C1, S1, C2, S2, C3, S3, C4, S4, C5, S5
Upvotes: 0
Views: 136
Reputation: 61
If the order is not important, you can try this:
paste(sort(paste(c("C","S"),rep(seq(1,5),2), sep = "")), collapse = ", ")
And you will get this result:
C1, C2, C3, C4, C5, S1, S2, S3, S4, S5
Upvotes: 1