purrr
purrr copied to clipboard
chuck() is a non-intuitive name
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:
- Make clearer that
chuck()
doesn't actually discard/get rid of an element in the documentation. - 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"
I take issue with this issue title 😂
To be serious, though, +1 for your suggestions.
chuck()
, throws, or chucks, errors. We'll add this to the docs.
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))
}