On Jan 29, 2014 5:47 PM, "Trevor Davies" <davies.trevor@gmail.com> wrote:
>
> Hi Hadley,
>
> Thanks for getting back to me - the dplyr package seems really great.
>
> The issue I have is that the groupings no longer works when I'm using the
> plyr::summarise function

That is presumably why you should load plyr first...
>
> Here is my code, I think it's pretty obvious what I'm trying to do:
>
> data_df <- tbl_df(full.data)
> group_year <- group_by(data_df,unique.i)
> skate.ddply <- dplyr::summarise(group_year,COR.TOW.SUM=sum(COR.CLEN))
>
>
> -> Here are the results comparing the two plyr & dplyr function
>
> Here are the results comparing the use of the plyr and dplyr
> =========== dplyr ============
> Browse[2]> dplyr::summarise(group_year,COR.TOW.SUM=sum(COR.CLEN))
> Source: local data frame [7,757 x 2]
>
>         unique.i COR.TOW.SUM
> 1  NED2013022.77           0
> 2  NED2013022.70           0
> 3  NED2013022.66           0
> 4  NED2013022.60           0
> 5  NED2013022.57           0
> 6  NED2013022.79           0
> 7  NED2013022.78           0
> 8  NED2013022.61           0
> 9  NED2013022.52           0
> 10 NED2013022.48           0
> ..           ...         ...
> ============== plyr ===========
> Browse[2]> plyr::summarise(group_year,COR.TOW.SUM=sum(COR.CLEN))
>   COR.TOW.SUM
> 1    31822.06
>
>
>
>
> On Wed, Jan 29, 2014 at 2:35 PM, Hadley Wickham <h.wickham@gmail.com>
wrote:
>
> > If you load plyr first, then dplyr, I think everything should work.
> > dplyr::summarise works similarly enough to plyr::summarise that it
> > shouldn't cause problems.
> >
> > Hadley
> >
> > On Wed, Jan 29, 2014 at 4:19 PM, Trevor Davies <davies.trevor@gmail.com>
> > wrote:
> > > I think I have a hole in my understanding of how R uses packages (or
at
> > > least how it gives functions in packages priority).  I thought I would
> > give
> > > the new dplyr package a test drive this morning (which is blazingly
fast
> > > BTW) and I've gone down the rabbit hole.
> > >
> > > The issue is that I'm unable to use both plyr and dplyr in a program
that
> > > I'm writing.  When I initially install dplyr and I look at the
summarise
> > > function everything works great but if I then install the plyr package
> > the
> > > summarise function from dplyr is then masked with the plyr summarise
> > > function taking priority.  I can't seem to figure out a way to get the
> > > dplyr summarise to become the main function...
> > >
> > > What am I missing here? Can you not use the dplyr and plyr packages at
> > the
> > > same time?
> > >
> > >
> > > Example:
> > > =========================
> > >> require(dplyr)
> > > Loading required package: dplyr
> > >
> > > Attaching package: 'dplyr'
> > >
> > > The following objects are masked from 'package:stats':
> > >
> > >     filter, lag
> > >
> > > The following objects are masked from 'package:base':
> > >
> > >     intersect, setdiff, setequal, union
> > >
> > >> summarise
> > > function (.data, ...)
> > > UseMethod("summarise")
> > > <environment: namespace:dplyr>
> > >>
> > > =======================
> > > ***However, if I then install plyr I get what is below and masks the
> > dplyr
> > > summarise function:**
> > >
> > >> require(plyr)
> > > Loading required package: plyr
> > > Attaching package: 'plyr'
> > > The following objects are masked from 'package:dplyr':
> > >     arrange, desc, failwith, id, mutate, summarise
> > >> summarise
> > > function (.data, ...)
> > > {
> > >     stopifnot(is.data.frame(.data) || is.list(.data) ||
> > > is.environment(.data))
> > > ....
> > > ...}
> > > <environment: namespace:plyr>
> > >>
> > > ===============
> > > ** Then no going back...
> > > require(dplyr)
> > >> summarise
> > > function (.data, ...)
> > > {
> > >     stopifnot(is.data.frame(.data) || is.list(.data) ||
> > > is.environment(.data))
> > > ....
> > > ...}
> > > <environment: namespace:plyr>
> > >>
> > >
> > >         [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > R-help@r-project.org mailing list
> > > 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.
> >
> >
> >
> > --
> > http://had.co.nz/
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> 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.

	[[alternative HTML version deleted]]


