Alternatively, melt() from the reshape2 package. library(reshape2) melt(x,id.vars="date",measure.vars=c("down","uc","up"),variable.name ="direction",value.name="percentage") HTH, Eric On Mon, Aug 17, 2020 at 10:49 AM Thierry Onkelinx via R-help < r-help at r-project.org> wrote:> You are looking for tidyr::pivot_longer() > > Best regards, > > ir. Thierry Onkelinx > Statisticus / Statistician > > Vlaamse Overheid / Government of Flanders > INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND > FOREST > Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance > thierry.onkelinx at inbo.be > Havenlaan 88 bus 73, 1000 Brussel > www.inbo.be > > > /////////////////////////////////////////////////////////////////////////////////////////// > To call in the statistician after the experiment is done may be no more > than asking him to perform a post-mortem examination: he may be able to say > what the experiment died of. ~ Sir Ronald Aylmer Fisher > The plural of anecdote is not data. ~ Roger Brinner > The combination of some data and an aching desire for an answer does not > ensure that a reasonable answer can be extracted from a given body of data. > ~ John Tukey > > /////////////////////////////////////////////////////////////////////////////////////////// > > <https://www.inbo.be> > > > Op ma 17 aug. 2020 om 09:35 schreef John <miaojpm at gmail.com>: > > > Is there any quick way (dplyr?) to arrange the data > > date down uc up > > 2019M08 0.01709827 0.2653882 0.7175136 > > 2019M09 0.02094724 0.2265797 0.7524731 > > 2019M10 0.01750911 0.2450030 0.7374879 > > > > to > > date direction percentage > > 2019M08 down 0.01709827 > > 2019M09 down 0.02094724 > > 2019M10 down 0.01750911 > > 2019M08 uc 0.2653882 > > 2019M09 uc 0.2265797 > > 2019M10 uc 0.2450030 > > 2019M08 up 0.7175136 > > 2019M09 up 0.7524731 > > 2019M10 up 0.7374879 > > > > [[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. > > > > [[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. >[[alternative HTML version deleted]]
Yes. However reshape2 is a retired package. The author recommends to use his new package tidyr. ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance thierry.onkelinx at inbo.be Havenlaan 88 bus 73, 1000 Brussel www.inbo.be /////////////////////////////////////////////////////////////////////////////////////////// To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey /////////////////////////////////////////////////////////////////////////////////////////// <https://www.inbo.be> Op ma 17 aug. 2020 om 09:52 schreef Eric Berger <ericjberger at gmail.com>:> Alternatively, melt() from the reshape2 package. > > library(reshape2) > melt(x,id.vars="date",measure.vars=c("down","uc","up"),variable.name > ="direction",value.name="percentage") > > HTH, > Eric > > > On Mon, Aug 17, 2020 at 10:49 AM Thierry Onkelinx via R-help < > r-help at r-project.org> wrote: > >> You are looking for tidyr::pivot_longer() >> >> Best regards, >> >> ir. Thierry Onkelinx >> Statisticus / Statistician >> >> Vlaamse Overheid / Government of Flanders >> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND >> FOREST >> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance >> thierry.onkelinx at inbo.be >> Havenlaan 88 bus 73, 1000 Brussel >> www.inbo.be >> >> >> /////////////////////////////////////////////////////////////////////////////////////////// >> To call in the statistician after the experiment is done may be no more >> than asking him to perform a post-mortem examination: he may be able to >> say >> what the experiment died of. ~ Sir Ronald Aylmer Fisher >> The plural of anecdote is not data. ~ Roger Brinner >> The combination of some data and an aching desire for an answer does not >> ensure that a reasonable answer can be extracted from a given body of >> data. >> ~ John Tukey >> >> /////////////////////////////////////////////////////////////////////////////////////////// >> >> <https://www.inbo.be> >> >> >> Op ma 17 aug. 2020 om 09:35 schreef John <miaojpm at gmail.com>: >> >> > Is there any quick way (dplyr?) to arrange the data >> > date down uc up >> > 2019M08 0.01709827 0.2653882 0.7175136 >> > 2019M09 0.02094724 0.2265797 0.7524731 >> > 2019M10 0.01750911 0.2450030 0.7374879 >> > >> > to >> > date direction percentage >> > 2019M08 down 0.01709827 >> > 2019M09 down 0.02094724 >> > 2019M10 down 0.01750911 >> > 2019M08 uc 0.2653882 >> > 2019M09 uc 0.2265797 >> > 2019M10 uc 0.2450030 >> > 2019M08 up 0.7175136 >> > 2019M09 up 0.7524731 >> > 2019M10 up 0.7374879 >> > >> > [[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. >> > >> >> [[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. >> >[[alternative HTML version deleted]]
Thanks for this information Thierry. I was not aware. The author of the packages is Hadley Wickham. He writes on Github that he does plan to make changes necessary to keep the package available on CRAN. On Mon, Aug 17, 2020 at 11:23 AM Thierry Onkelinx <thierry.onkelinx at inbo.be> wrote:> Yes. However reshape2 is a retired package. The author recommends to use > his new package tidyr. > > ir. Thierry Onkelinx > Statisticus / Statistician > > Vlaamse Overheid / Government of Flanders > INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND > FOREST > Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance > thierry.onkelinx at inbo.be > Havenlaan 88 bus 73, 1000 Brussel > www.inbo.be > > > /////////////////////////////////////////////////////////////////////////////////////////// > To call in the statistician after the experiment is done may be no more > than asking him to perform a post-mortem examination: he may be able to say > what the experiment died of. ~ Sir Ronald Aylmer Fisher > The plural of anecdote is not data. ~ Roger Brinner > The combination of some data and an aching desire for an answer does not > ensure that a reasonable answer can be extracted from a given body of data. > ~ John Tukey > > /////////////////////////////////////////////////////////////////////////////////////////// > > <https://www.inbo.be> > > > Op ma 17 aug. 2020 om 09:52 schreef Eric Berger <ericjberger at gmail.com>: > >> Alternatively, melt() from the reshape2 package. >> >> library(reshape2) >> melt(x,id.vars="date",measure.vars=c("down","uc","up"),variable.name >> ="direction",value.name="percentage") >> >> HTH, >> Eric >> >> >> On Mon, Aug 17, 2020 at 10:49 AM Thierry Onkelinx via R-help < >> r-help at r-project.org> wrote: >> >>> You are looking for tidyr::pivot_longer() >>> >>> Best regards, >>> >>> ir. Thierry Onkelinx >>> Statisticus / Statistician >>> >>> Vlaamse Overheid / Government of Flanders >>> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE >>> AND >>> FOREST >>> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance >>> thierry.onkelinx at inbo.be >>> Havenlaan 88 bus 73, 1000 Brussel >>> www.inbo.be >>> >>> >>> /////////////////////////////////////////////////////////////////////////////////////////// >>> To call in the statistician after the experiment is done may be no more >>> than asking him to perform a post-mortem examination: he may be able to >>> say >>> what the experiment died of. ~ Sir Ronald Aylmer Fisher >>> The plural of anecdote is not data. ~ Roger Brinner >>> The combination of some data and an aching desire for an answer does not >>> ensure that a reasonable answer can be extracted from a given body of >>> data. >>> ~ John Tukey >>> >>> /////////////////////////////////////////////////////////////////////////////////////////// >>> >>> <https://www.inbo.be> >>> >>> >>> Op ma 17 aug. 2020 om 09:35 schreef John <miaojpm at gmail.com>: >>> >>> > Is there any quick way (dplyr?) to arrange the data >>> > date down uc up >>> > 2019M08 0.01709827 0.2653882 0.7175136 >>> > 2019M09 0.02094724 0.2265797 0.7524731 >>> > 2019M10 0.01750911 0.2450030 0.7374879 >>> > >>> > to >>> > date direction percentage >>> > 2019M08 down 0.01709827 >>> > 2019M09 down 0.02094724 >>> > 2019M10 down 0.01750911 >>> > 2019M08 uc 0.2653882 >>> > 2019M09 uc 0.2265797 >>> > 2019M10 uc 0.2450030 >>> > 2019M08 up 0.7175136 >>> > 2019M09 up 0.7524731 >>> > 2019M10 up 0.7374879 >>> > >>> > [[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. >>> > >>> >>> [[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. >>> >>[[alternative HTML version deleted]]
Thanks! Thierry Onkelinx <thierry.onkelinx at inbo.be> ? 2020?8?17? ?? ??4:23???> Yes. However reshape2 is a retired package. The author recommends to use > his new package tidyr. > > ir. Thierry Onkelinx > Statisticus / Statistician > > Vlaamse Overheid / Government of Flanders > INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND > FOREST > Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance > thierry.onkelinx at inbo.be > Havenlaan 88 bus 73, 1000 Brussel > www.inbo.be > > > /////////////////////////////////////////////////////////////////////////////////////////// > To call in the statistician after the experiment is done may be no more > than asking him to perform a post-mortem examination: he may be able to say > what the experiment died of. ~ Sir Ronald Aylmer Fisher > The plural of anecdote is not data. ~ Roger Brinner > The combination of some data and an aching desire for an answer does not > ensure that a reasonable answer can be extracted from a given body of data. > ~ John Tukey > > /////////////////////////////////////////////////////////////////////////////////////////// > > <https://www.inbo.be> > > > Op ma 17 aug. 2020 om 09:52 schreef Eric Berger <ericjberger at gmail.com>: > >> Alternatively, melt() from the reshape2 package. >> >> library(reshape2) >> melt(x,id.vars="date",measure.vars=c("down","uc","up"),variable.name >> ="direction",value.name="percentage") >> >> HTH, >> Eric >> >> >> On Mon, Aug 17, 2020 at 10:49 AM Thierry Onkelinx via R-help < >> r-help at r-project.org> wrote: >> >>> You are looking for tidyr::pivot_longer() >>> >>> Best regards, >>> >>> ir. Thierry Onkelinx >>> Statisticus / Statistician >>> >>> Vlaamse Overheid / Government of Flanders >>> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE >>> AND >>> FOREST >>> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance >>> thierry.onkelinx at inbo.be >>> Havenlaan 88 bus 73, 1000 Brussel >>> www.inbo.be >>> >>> >>> /////////////////////////////////////////////////////////////////////////////////////////// >>> To call in the statistician after the experiment is done may be no more >>> than asking him to perform a post-mortem examination: he may be able to >>> say >>> what the experiment died of. ~ Sir Ronald Aylmer Fisher >>> The plural of anecdote is not data. ~ Roger Brinner >>> The combination of some data and an aching desire for an answer does not >>> ensure that a reasonable answer can be extracted from a given body of >>> data. >>> ~ John Tukey >>> >>> /////////////////////////////////////////////////////////////////////////////////////////// >>> >>> <https://www.inbo.be> >>> >>> >>> Op ma 17 aug. 2020 om 09:35 schreef John <miaojpm at gmail.com>: >>> >>> > Is there any quick way (dplyr?) to arrange the data >>> > date down uc up >>> > 2019M08 0.01709827 0.2653882 0.7175136 >>> > 2019M09 0.02094724 0.2265797 0.7524731 >>> > 2019M10 0.01750911 0.2450030 0.7374879 >>> > >>> > to >>> > date direction percentage >>> > 2019M08 down 0.01709827 >>> > 2019M09 down 0.02094724 >>> > 2019M10 down 0.01750911 >>> > 2019M08 uc 0.2653882 >>> > 2019M09 uc 0.2265797 >>> > 2019M10 uc 0.2450030 >>> > 2019M08 up 0.7175136 >>> > 2019M09 up 0.7524731 >>> > 2019M10 up 0.7374879 >>> > >>> > [[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. >>> > >>> >>> [[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. >>> >>[[alternative HTML version deleted]]