MYaseen208
MYaseen208

Reputation: 23898

Creating character vector with comma separator and without double quotes in R using paste command

Desired result:

s1,s2,s3,s4,s5,s6,s7,s8,s9,s10

I want to get a character vector with comma separator and without double quotes using R paste0 command. MWE is given below:

noquote(paste0("s", 1:10))

Could not figured out how to append comma between two elements of the character vector.

Upvotes: 1

Views: 1501

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 520948

Try using the collapse parameter with paste to concatenate to a single comma separated string.

paste0("s", 1:10, collapse=",")
[1] "s1,s2,s3,s4,s5,s6,s7,s8,s9,s10"

Demo

Upvotes: 2

Related Questions