I am sick and tired of writing:
paste(paste(letters[1:3], collapse=" "), "foo")
In order to get:
[1] "a b c foo"
particularly because the collapse
argument must be fully typed since it follows the ...
. cat
does this very easily:
cat(letters[1:3], "foo")
but does not return a value (grrr). Is there any base (or otherwise R default preloaded package) function that behaves like cat
does and actually returns a value?
Clearly there are several ways of building such a function, but I can't believe there isn't something already pre-existing.
One possible semi-okay solution I just thought of:
paste(c(letters[1:3], "foo"), collapse=" ")
But again annoying because of the need to fully type out collapse
.
You could try
Reduce(paste, c(letters[1:3], 'foo'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With