On Thu, 18 Nov 2021 16:40:14 -0500 "Christopher W. Ryan via R-help" <r-help@r-project.org> wrote:
> I've just learned about pluck() and chuck() in the purrr package. Very > cool! As I understand it, they both will return one element of a > list, either by name or by [[]] index, or even "first" or "last" > > I was hoping to find a way to return all *but* one specified element > of a list. Speaking loosely, pluck(-1) or pluck(!1) or !pluck(1), but > none of those of course work. Thinking of English language, I had > hopes for chuck(1) as in "chuck element 1 away, leaving the rest" > but that's now how it works. > > Any tidyverse-centric ways to return all except one specified element > of a list? Why (on earth!) hand-cuff yourself to someone else's prescription of how things should be done? Why not just do it yourself, especially given that it's so easy in this instance? Use mung[[1]] to get the first entry of a list named "mung". Or mung[1] of one if you want a *list* whose sole entry is the first entry of mung. Likewise mung[-1] will give you the "all but" results. Fewer key strokes, even. Tell tidyverse/purrr to pluck off! :-) cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.