A recipe for dynamic programming in R: Solving a “quadruel” case from PuzzlOR – Serhat's Blog. As also described in Cormen, et al (2009) p. 65, in algorithm design, divide-and-conquer paradigm incorporates a recursive approach in which the main problem is: Divided into smaller sub-problems (divide),The sub-problems are solved (conquer),And the solutions to sub-problems are combined to solve the original and “bigger” problem (combine). Instead of constructing indefinite number of nested loops destroying the readability of the code and the performance of execution, the “recursive” way utilizes just one block of code which calls itself (hence the term “recursive”) for the smaller problem.
The main point is to define a “stop” rule, so that the function does not sink into an infinite recursion depth. While nested loops modify the same object (or address space in the low level sense), recursion moves the “stack pointer”, so each recursion depth uses a different part of the stack (a copy of the objects will be created for each recursion). The question goes as follows: Notes:
How to use a Google Spreadsheet as data in R. One of the great strengths of R is that it promotes reproducible research: as an open-source system, you can easily send a script file to a colleague with the confidence that they'll be able to get the same results using R on their own system. Provided they have the same data, that is. If that's your goal, you can always send along a data file, but that can add some complications. You have to take care with the filenames in your script, and dealing with data that changes regularly can be annoying.
Google Docs offers a solution. As long as you have a Google account, you can store your data as a Google Spreadsheet, and then create a special URL for that spreadsheet that can be used as a CSV file source by R. The process is a bit complex, but it only needs to be done once, and then your data are freely available to anyone who wants to access it via R. Open your spreadsheet in Google Docs.Click the "Share" botton in the toolbar, and choose "Anyone with the link" for Visibility options.