Join GitHub today
Update loop lession so that the first example follows lesson #674
This is a great improvement on the existing example. I'd add a definition of the variable. The word variable appears first at line 77, and I suspect people might not immediately see that we refer to "filename".
Maybe something along these lines could replace lines 76-78:
Sorry that this PR seems to have fallen through the cracks for a while. (Thanks for bumping, @cdarabos )
A surface problem with this change is that it renders a later part of the episode ("Going back to our original file copying problem, we can solve it using this loop:...") redundant.
But more fundamentally, I don't think I like throwing the solution to the backup problem at them right away. I think there are some execution problems with this part of the episode as it currently exists, but I like the overall approach it takes of starting with a relatively simple for loop, and building up to the final goal (adding pieces as we go about concatenating with variables and using wildcards in the loop).
Hi! I also noticed that the example did not follow the problem that was set up during my instructor demo lesson as well - it was awkward to teach. In teaching for loops in R to a class recently, I did find it helpful to show a task that would take a long time without loops and then immediately show how to do it in a loop - to give the learners a motivation as to why you would want to use a loop.
Here's my suggestion: