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

last (?) argument to collapse #9

Closed
hadley opened this issue Jan 4, 2017 · 3 comments
Closed

last (?) argument to collapse #9

hadley opened this issue Jan 4, 2017 · 3 comments

Comments

@hadley
Copy link
Member

hadley commented Jan 4, 2017

So you can do:

collapse(1:4, ",", last = ", and ")
#> 1, 2, 3, and 4
@jimhester
Copy link
Collaborator

Oxford comma, surprising hadley!

@jonocarroll
Copy link

r-lib/cli#128 (for tidy developer day) can be resolved by adding this feature. What do you think about an oxford = TRUE for when there are >= 3 arguments? I'm happy to make the PR for that.

@math-mcshane
Copy link

I thought I had an original idea to introduce an oxford = TRUE parameter to glue_collapse (presumably the successor to collapse). It looks like I wasn't the first.

If there was a oxford = TRUE parameter, AFAIK, it's gone/inaccessible now:

glue::glue_collapse(x = 1:4, sep = ", ", last = ", and ")
#> 1, 2, 3, and 4
try(glue::glue_collapse(x = 1:4, sep = ", ", last = " and ", oxford = TRUE))
#> Error in glue::glue_collapse(x = 1:4, sep = ", ", last = " and ", oxford = TRUE) : 
#>   unused argument (oxford = TRUE)

I am also not seeing a collapse in cli, FWIW, just successor functions.

Signed, pro-Oxford comma guy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants