slice() vs. head() (and do)

97 views
Skip to first unread message

Bob

unread,
Oct 27, 2014, 9:59:30 AM10/27/14
to manip...@googlegroups.com
Hi All,

I just had a "Doh!" moment I thought I'd share. I had not really caught on to the importance of the slice() function. It seemed just like head() or tail(). Then I used head() on a data frame that had been run through group_by(). It only printed the head of the whole data frame since it has no idea that the grouped indices were set.  slice() did it by group of course. That's where do() comes in. It can make any function work on group_by info and so it can make head() work like slice() on grouped data, but slice() is so much easier.

Cheers,
Bob

Grant Rettke

unread,
Oct 29, 2014, 9:30:35 AM10/29/14
to Bob, manip...@googlegroups.com
Thanks for sharing that experience; it is valuable to those learning
this framework.
> --
> You received this message because you are subscribed to the Google Groups
> "manipulatr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to manipulatr+...@googlegroups.com.
> To post to this group, send email to manip...@googlegroups.com.
> Visit this group at http://groups.google.com/group/manipulatr.
> For more options, visit https://groups.google.com/d/optout.



--
Grant Rettke
g...@wisdomandwonder.com | http://www.wisdomandwonder.com/
“Wisdom begins in wonder.” --Socrates
((λ (x) (x x)) (λ (x) (x x)))
“Life has become immeasurably better since I have been forced to stop
taking it seriously.” --Thompson
Reply all
Reply to author
Forward
0 new messages