purrr icon indicating copy to clipboard operation
purrr copied to clipboard

chuck() is a non-intuitive name

Open jzadra opened this issue 2 years ago • 1 comments

It seems to me that chuck() should be the opposite of pluck(), rather than a strict form of pluck().

Pluck means to take hold of (something) and quickly remove it from its place. "she plucked a blade of grass"

Chuck means to throw (something) carelessly or casually. "someone chucked a brick through the window"

So plucking something means you've selected something to keep. Chucking something means you've chosen something to get rid of. Yet if the element exists, pluck() and chuck() do the same thing.

As far as I can tell, there is actually no opposite to pluck(), where the list would be returned with everything except the element.

Suggestion:

  1. Make clearer that chuck() doesn't actually discard/get rid of an element in the documentation.
  2. Add a function that returns a list without the discarded element. Perhaps huck()?

Huck means to throw (something). "people have been hucking trash into the trees"

jzadra avatar Dec 28 '21 19:12 jzadra

I take issue with this issue title 😂

To be serious, though, +1 for your suggestions.

chorgan182 avatar Jul 12 '22 15:07 chorgan182

chuck(), throws, or chucks, errors. We'll add this to the docs.

hadley avatar Aug 23 '22 21:08 hadley

Here's my huck in case it's of interest:

huck <- function(.data, ...) 
{
  vars <- rlang::names2(.data)
  vars <- tidyselect::vars_select(vars, ...)
  within(.data, rm(list = vars))
}

jzadra avatar Aug 23 '22 21:08 jzadra