I've set myself the task of learning about these packages, and about tidy data concepts. What is the relationship between plyr and dplyr? Does the latter replace the former (meaning I can concentrate on learning the latter)? Or is there ever a need to use functions from both (meaning I should learn both)? Thanks. --Chris Ryan
Hello, Maybe you should ask the maintainer of both packages.> maintainer("plyr")[1] "Hadley Wickham <hadley at rstudio.com>"> maintainer("dplyr")[1] "Hadley Wickham <hadley at rstudio.com>" Hope this helps, Rui Barradas Citando Christopher W Ryan <cryan at binghamton.edu>:> I've set myself the task of learning about these packages, and about > tidy data concepts. > > What is the relationship between plyr and dplyr? Does the latter > replace the former (meaning I can concentrate on learning the latter)? > Or is there ever a need to use functions from both (meaning I should > learn both)? > > Thanks. > > --Chris Ryan > > ______________________________________________ > R-help at 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.
I see no reason to bother Hadley in the age of google. Search on "dplyr versus plyr" and read what you get! (on the first hit, even) Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Sep 15, 2016 at 7:20 AM, <ruipbarradas at sapo.pt> wrote:> Hello, > > Maybe you should ask the maintainer of both packages. > >> maintainer("plyr") > > [1] "Hadley Wickham <hadley at rstudio.com>" >> >> maintainer("dplyr") > > [1] "Hadley Wickham <hadley at rstudio.com>" > > Hope this helps, > > Rui Barradas > > > > Citando Christopher W Ryan <cryan at binghamton.edu>: > > >> I've set myself the task of learning about these packages, and about >> tidy data concepts. >> >> What is the relationship between plyr and dplyr? Does the latter >> replace the former (meaning I can concentrate on learning the latter)? >> Or is there ever a need to use functions from both (meaning I should >> learn both)? >> >> Thanks. >> >> --Chris Ryan >> >> ______________________________________________ >> R-help at 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. > > > ______________________________________________ > R-help at 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.
Hello Christopher and others : What cannot be stressed enough is: do not combine both packages, it gives errors and incorrect results! I will show that below -------------------------------------------------------- a<-data.frame(groep=1:4,v=1:40) library(dplyr) a %>% group_by(groep) %>% summarise(m=mean(v),n=n()) # groep m n # <int> <dbl> <int> # 1 1 19 10 # 2 2 20 10 # 3 3 21 10 # 4 4 22 10 # correct library(plyr) a %>% group_by(groep) %>% summarise(m=mean(v),n=n()) Error in n() : This function should not be called directly # ??? a %>% group_by(groep) %>% summarise(m=mean(v)) # m # 1 20.5 #incorrect! -------------------------------------------------- So both n() and group_by from dplyr don't work after library(plyr)! My advice is: do not use plyr. Unfortunately plyr has some functions that are very important, and that are not in dplyr. For instance: rbind.fill() (for combining the rows of two dataframes with unequal columns). If you need this: do'nt library plyr, use plyr::rbind.fil Until now I have the impression that it is also possible to library dplyr after plyr, but it is better to remove plyr! This is a serious problem that has been reported before, but not solved (in dplyr 0.5.0 and plyr 1.8.4) Frams 2016-09-15 16:09 GMT+02:00 Christopher W Ryan <cryan at binghamton.edu>:> I've set myself the task of learning about these packages, and about > tidy data concepts. > > What is the relationship between plyr and dplyr? Does the latter > replace the former (meaning I can concentrate on learning the latter)? > Or is there ever a need to use functions from both (meaning I should > learn both)? > > Thanks. > > --Chris Ryan > > ______________________________________________ > R-help at 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. >[[alternative HTML version deleted]]
Thank you Frans. This is exactly the sort of nuance that I want to learn about. --Chris Frans Marcelissen wrote:> Hello Christopher and others > : > What cannot be stressed enough is: do not combine both packages, it > gives errors and incorrect results! I will show that below > -------------------------------------------------------- > a<-data.frame(groep=1:4,v=1:40) > library(dplyr) > a %>% group_by(groep) %>% summarise(m=mean(v),n=n()) > # groep m n > # <int> <dbl> <int> > # 1 1 19 10 > # 2 2 20 10 > # 3 3 21 10 > # 4 4 22 10 > # correct > > library(plyr) > a %>% group_by(groep) %>% summarise(m=mean(v),n=n()) > > Error in n() : This function should not be called directly > # ??? > a %>% group_by(groep) %>% summarise(m=mean(v)) > # m > # 1 20.5 > #incorrect! > -------------------------------------------------- > > So both n() and group_by from dplyr don't work after library(plyr)! > > My advice is: do not use plyr. Unfortunately plyr has some functions > that are very important, and that are not in dplyr. For > instance: rbind.fill() (for combining the rows of two dataframes with > unequal columns). If you need this: do'nt library plyr, use plyr::rbind.fil > > Until now I have the impression that it is also possible to library > dplyr after plyr, but it is better to remove plyr! > > This is a serious problem that has been reported before, but not solved > (in dplyr 0.5.0 and plyr 1.8.4) > > Frams > > 2016-09-15 16:09 GMT+02:00 Christopher W Ryan <cryan at binghamton.edu > <mailto:cryan at binghamton.edu>>: > > I've set myself the task of learning about these packages, and about > tidy data concepts. > > What is the relationship between plyr and dplyr? Does the latter > replace the former (meaning I can concentrate on learning the latter)? > Or is there ever a need to use functions from both (meaning I should > learn both)? > > Thanks. > > --Chris Ryan > > ______________________________________________ > R-help at r-project.org <mailto:R-help at r-project.org> mailing list -- > To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > <https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > <http://www.R-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > >
The incorrect results are unfortunate and can trip up the inexperienced user, but this problem is straightforward to resolve if you explicitly specify which versions of the conflicting functions to use. The more interesting question I saw was whether the intent is to deprecate plyr, but so far that does not appear to be the case. While I agree that mixing them can be trouble-prone, I think in many cases both will continue to be used. -- Sent from my phone. Please excuse my brevity. On September 15, 2016 10:08:05 AM PDT, Frans Marcelissen <fransiepansiekevertje at gmail.com> wrote:>Hello Christopher and others >: >What cannot be stressed enough is: do not combine both packages, it >gives >errors and incorrect results! I will show that below >-------------------------------------------------------- >a<-data.frame(groep=1:4,v=1:40) >library(dplyr) >a %>% group_by(groep) %>% summarise(m=mean(v),n=n()) ># groep m n ># <int> <dbl> <int> ># 1 1 19 10 ># 2 2 20 10 ># 3 3 21 10 ># 4 4 22 10 ># correct > >library(plyr) >a %>% group_by(groep) %>% summarise(m=mean(v),n=n()) > >Error in n() : This function should not be called directly ># ??? >a %>% group_by(groep) %>% summarise(m=mean(v)) ># m ># 1 20.5 >#incorrect! >-------------------------------------------------- > >So both n() and group_by from dplyr don't work after library(plyr)! > >My advice is: do not use plyr. Unfortunately plyr has some functions >that >are very important, and that are not in dplyr. For instance: >rbind.fill() >(for combining the rows of two dataframes with unequal columns). If you >need this: do'nt library plyr, use plyr::rbind.fil > >Until now I have the impression that it is also possible to library >dplyr >after plyr, but it is better to remove plyr! > >This is a serious problem that has been reported before, but not solved >(in >dplyr 0.5.0 and plyr 1.8.4) > >Frams > >2016-09-15 16:09 GMT+02:00 Christopher W Ryan <cryan at binghamton.edu>: > >> I've set myself the task of learning about these packages, and about >> tidy data concepts. >> >> What is the relationship between plyr and dplyr? Does the latter >> replace the former (meaning I can concentrate on learning the >latter)? >> Or is there ever a need to use functions from both (meaning I should >> learn both)? >> >> Thanks. >> >> --Chris Ryan >> >> ______________________________________________ >> R-help at 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. >> > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at 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.