Creating a comma separated vector

shQuote is probably the best way to do this. Specifically, this gets you the output you want:

cat(paste(shQuote(one, type="cmd"), collapse=", "))

If single quotes are fine, you can use:

paste(shQuote(one), collapse=", ")

type="cmd" actually provides escaped quotes, which is what’s actually useful for most contexts, but if you really want to display it somewhere with unescaped quotes, cat provides that.

Leave a Comment