0

I notice in different packages it sometimes refers to a variable, a column to sort by, an object, etc. Like in dplyr it usually refers to a variable, but in ggplot, it's not even used.

Is there any logic behind this? Is there any universality? Or can it just be anything.

moodymudskipper
  • 46,417
  • 11
  • 121
  • 167
Chris
  • 59
  • 5
  • 2
    In base R, yes. But *dplyr* dares to be different. It means whatever the help file says it means. – Rich Scriven May 05 '18 at 21:18
  • It's just a way of allowing an arbitrary number of parameters to be passed. If the function handles the dots directly, the docs are usually good. However, I find problems frequently arise when they're instead passed to separately-documented methods, as then you've got to figure out what method is being called so you can look up the appropriate docs to find out what parameters can usefully be passed to `...`. It's not a beginner-friendly process. – alistaire May 05 '18 at 21:40
  • 2
    Possible duplicate of [Usage of \`...\` (three-dots or dot-dot-dot) in functions](https://stackoverflow.com/questions/5890576/usage-of-three-dots-or-dot-dot-dot-in-functions) – moodymudskipper May 06 '18 at 00:49

1 Answers1

1

It can accept an arbitrary number of formal parameters. In base R these parameters are often arguments to other functions. The Arguments description in the function's help page should indicate which subsequent functions will be getting these arguments. It can be the only argument, the first, the last, or it can be intercalated in the parameter list. The items in the list(...) generally should be named. You can access the items in the "dots" list in a couple of different ways: ...() and list(...) are two that I've seen. Generally, it is the R-cognoscenti that will be designing functions with these forms. When it is intercalated (or the first), the named parameters that follow it in the formals must be named when the function is called and cannot be assigned positionally. If you type ?'...' you will be shown the Reserved page, which in turn has a link to dotsMethods {methods}.

I found it difficult to search for [r] with "..." using a SO search panel but searching on "[r] dotsMethods" brought up 10 hits.

IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • The `ellipsis` tag is often used, I added it to this question, it's usually used on `css` questions though. [r][ellipsis] returns two pages. – moodymudskipper May 06 '18 at 00:44
  • The form `...()` was offered on the R-devel mailing list this week as part of a discussion of a request for the getting the length of `...`-arguments. One could search the May archives https://stat.ethz.ch/pipermail/r-devel/2018-May/thread.html for "[Rd] length of `...`" where teh ellipsis is enclosed in backticks. I get 19 hits. – IRTFM May 06 '18 at 01:33