Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid partial matching #186

Merged
merged 4 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion syntax.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,23 @@ mean(x = 1:10, , FALSE)
mean(, TRUE, x = c(1:10, NA))
```

Avoid partial matching.
### Avoid partial matching

Always spell-out the complete argument names. Although the R execution tries to save you time by matching partially-completed names, do not rely on this. Partial maching is less consistent and less readable. Furthermore, the function signature may be updated in the future, and the partial match may become ambiguous.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a typo: "maching" -> "matching".


```{r, eval = FALSE}
# Good
rep(1:2, times = 3)
cut(1:10, breaks = c(0, 4, 11))
seq.int(0, 1, length.out = 11)

# Bad
rep(1:2, t = 3)
cut(1:10, b = c(0, 4, 11))
seq.int(0, 1, len = 11)
```

IDEs common allow the user to auto-complete arguments, which may save a little time. For example, RStudio's code completion [uses the tab button](https://support.rstudio.com/hc/en-us/articles/205273297-Code-Completion-in-the-RStudio-IDE)

### Assignment

Expand Down