2

Trying to create a modified version of paste function where any input text needs to be bracketed by "stop" and "start". Failing code is:

telegram.paste <- function(...) {paste("START", "...", "STOP")}

As a fairly new user I'm struggling to identify the issue with my code and either an explanation or link to one would be very much appreciated.

www
  • 38,575
  • 12
  • 48
  • 84
Rose Savage
  • 61
  • 1
  • 4
  • Loose the quotes around `...`: try `telegram.paste <- function(...) {paste("START",..., "STOP")}` – Val Jun 14 '17 at 09:53

1 Answers1

3

You are using the ellipsis .... If you want to pass these arguments to paste you have to remove the " ". So

telegram.paste <- function(...) {paste("START", ..., "STOP")}

will work.

telegram.paste("This is a telegram")
# [1] "START This is a telegram STOP"
telegram.paste("This", "will", "work", "also")
# [1] "START This will work also STOP"
theSZ
  • 73
  • 7