R prevent repeated items while using paste() for vectors

I guess it depends what you want it for. If you are pasting this together to display in the R console, say as a note or information, then cat() works a bit more intuitively:

R> cat("The list is:", a, "\n")
The list is: 1 2 3 4 5 6 7 8 9 10

or

R> cat("The list is:", a, fill = TRUE)
The list is: 1 2 3 4 5 6 7 8 9 10

If you want the actual character string as an R object I don't think you'll get much simpler than the paste() idiom you show.

Tags:

R

Paste