Stephen Sefick
2013-May-31 02:57 UTC
[R] merge_recurse in libray reshape - how does it work?
merge_recurse function (dfs, ...) { if (length(dfs) == 2) { merge(dfs[[1]], dfs[[2]], all = TRUE, sort = FALSE, ...) } else { merge(dfs[[1]], Recall(dfs[-1]), all = TRUE, sort = FALSE, ...) } } I do not understand how the Recall part of this function works. Could somebody explain this to me? many thanks, -- Stephen Sefick ************************************************** Auburn University Biological Sciences 331 Funchess Hall Auburn, Alabama 36849 ************************************************** sas0025 at auburn.edu http://www.auburn.edu/~sas0025 ************************************************** Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis "A big computer, a complex algorithm and a long time does not equal science." -Robert Gentleman
Have you studied the Help file for Recall() . (It is not clear to me that you have). Do you understand what recursion is? ( this is a simple example of it). Try constructing a very simple example and then work through what the code does in it step by step. I'll leave it to others to attempt a mini-tutorial beyond this. -- Bert On Thu, May 30, 2013 at 7:57 PM, Stephen Sefick <sas0025 at auburn.edu> wrote:> merge_recurse > function (dfs, ...) > { > if (length(dfs) == 2) { > merge(dfs[[1]], dfs[[2]], all = TRUE, sort = FALSE, ...) > } > else { > merge(dfs[[1]], Recall(dfs[-1]), all = TRUE, sort = FALSE, > ...) > } > } > > I do not understand how the Recall part of this function works. Could > somebody explain this to me? > many thanks, > > > -- > Stephen Sefick > ************************************************** > Auburn University > Biological Sciences > 331 Funchess Hall > Auburn, Alabama > 36849 > ************************************************** > sas0025 at auburn.edu > http://www.auburn.edu/~sas0025 > ************************************************** > > Let's not spend our time and resources thinking about things that are so > little or so large that all they really do for us is puff us up and make us > feel like gods. We are mammals, and have not exhausted the annoying little > problems of being mammals. > > -K. Mullis > > "A big computer, a complex algorithm and a long time does not equal > science." > > -Robert Gentleman > > ______________________________________________ > R-help at 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.-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
Stephen Sefick
2013-May-31 14:10 UTC
[R] merge_recurse in libray reshape - how does it work?
Thanks for the help. I think I have it figured out... inside of merge dfs[-1] lops off the first element in the list and merges with dfs[[1]] then this is repeated for the entire list? With Recall inside of a function this process repeats until there are no more objects to merge? many thanks, Stephen On 05/30/2013 10:02 PM, Dennis Murphy wrote:> For the general purpose of Recall, this might help: > > http://rfunction.com/archives/364 > > It's typically used in recursive function definitions - e.g., the > Fibonacci series. > > Dennis > > On Thu, May 30, 2013 at 7:57 PM, Stephen Sefick <sas0025 at auburn.edu> wrote: >> merge_recurse >> function (dfs, ...) >> { >> if (length(dfs) == 2) { >> merge(dfs[[1]], dfs[[2]], all = TRUE, sort = FALSE, ...) >> } >> else { >> merge(dfs[[1]], Recall(dfs[-1]), all = TRUE, sort = FALSE, >> ...) >> } >> } >> >> I do not understand how the Recall part of this function works. Could >> somebody explain this to me? >> many thanks, >> >> >> -- >> Stephen Sefick >> ************************************************** >> Auburn University >> Biological Sciences >> 331 Funchess Hall >> Auburn, Alabama >> 36849 >> ************************************************** >> sas0025 at auburn.edu >> http://www.auburn.edu/~sas0025 >> ************************************************** >> >> Let's not spend our time and resources thinking about things that are so >> little or so large that all they really do for us is puff us up and make us >> feel like gods. We are mammals, and have not exhausted the annoying little >> problems of being mammals. >> >> -K. Mullis >> >> "A big computer, a complex algorithm and a long time does not equal >> science." >> >> -Robert Gentleman >> >> ______________________________________________ >> R-help at 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.
stephen sefick
2013-May-31 16:28 UTC
[R] merge_recurse in libray reshape - how does it work?
Bert, I have not studied the help in enough depth. My, limited, understanding of recursion comes from the linux command line - e.g., rm -r will remove all files in a folder by descending (probably not the right word) into the folder , removing all of the files, and then removing the folder itself. Thank you for all of the help. Stephen On Thu, May 30, 2013 at 11:25 PM, Bert Gunter <gunter.berton@gene.com>wrote:> Have you studied the Help file for Recall() . (It is not clear to me > that you have). Do you understand what recursion is? ( this is a > simple example of it). > > Try constructing a very simple example and then work through what the > code does in it step by step. > > I'll leave it to others to attempt a mini-tutorial beyond this. > > -- Bert > > On Thu, May 30, 2013 at 7:57 PM, Stephen Sefick <sas0025@auburn.edu> > wrote: > > merge_recurse > > function (dfs, ...) > > { > > if (length(dfs) == 2) { > > merge(dfs[[1]], dfs[[2]], all = TRUE, sort = FALSE, ...) > > } > > else { > > merge(dfs[[1]], Recall(dfs[-1]), all = TRUE, sort = FALSE, > > ...) > > } > > } > > > > I do not understand how the Recall part of this function works. Could > > somebody explain this to me? > > many thanks, > > > > > > -- > > Stephen Sefick > > ************************************************** > > Auburn University > > Biological Sciences > > 331 Funchess Hall > > Auburn, Alabama > > 36849 > > ************************************************** > > sas0025@auburn.edu > > http://www.auburn.edu/~sas0025 > > ************************************************** > > > > Let's not spend our time and resources thinking about things that are so > > little or so large that all they really do for us is puff us up and make > us > > feel like gods. We are mammals, and have not exhausted the annoying > little > > problems of being mammals. > > > > -K. Mullis > > > > "A big computer, a complex algorithm and a long time does not equal > > science." > > > > -Robert Gentleman > > > > ______________________________________________ > > 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. > > > > -- > > Bert Gunter > Genentech Nonclinical Biostatistics > > Internal Contact Info: > Phone: 467-7374 > Website: > > http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm > > >[[alternative HTML version deleted]]