What is the ... (dots) argument in R and when would you use it?

Quick Overview

Asks what the ... argument does in an R function and when you would use it. Tests whether you understand argument forwarding, variable-length inputs, how to inspect what a caller passed, and the risks the dots create for a function's interface.

What is the ... (dots) argument in R and when would you use it?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Other

What is the `...` (dots) argument in R and when would you use it? ```hint A thin wrapper Picture writing a small wrapper around `plot()` that fixes one setting and lets the caller pass anything else `plot()` accepts. ``` ### What a Strong Answer Covers - What the dots capture and how they can be passed on unchanged. - The situations where dots are the right tool. - How to inspect or capture the contents of the dots inside the function. - The cost to the function's interface and how to guard against it. ### Follow-up Questions - Why do S3 generics such as `print()` and `summary()` include `...` in their signatures? - `paste("a", "b", sep = "-")` works. How does R know that `sep` is not one of the strings to paste? - How would you make a function fail loudly when a caller passes an argument that nothing uses? - How do you capture the unevaluated expressions passed through the dots, for example to write a dplyr-style function?

Overview: Asks what the ... argument does in an R function and when you would use it. Tests whether you understand argument forwarding, variable-length inputs, how to inspect what a caller passed, and the risks the dots create for a function's interface.

PracHub logo
General
Nov 24, 2026
mediumData ScientistOtherData Manipulation (SQL/Python)
0
0

What is the ... (dots) argument in R and when would you use it?

What a Strong Answer Covers Guidance

  • What the dots capture and how they can be passed on unchanged.
  • The situations where dots are the right tool.
  • How to inspect or capture the contents of the dots inside the function.
  • The cost to the function's interface and how to guard against it.

Follow-up Questions Guidance

  • Why do S3 generics such as print() and summary() include ... in their signatures?
  • paste("a", "b", sep = "-") works. How does R know that sep is not one of the strings to paste?
  • How would you make a function fail loudly when a caller passes an argument that nothing uses?
  • How do you capture the unevaluated expressions passed through the dots, for example to write a dplyr-style function?