swcarpentry / r-novice-inflammation

Programming with R
http://swcarpentry.github.io/r-novice-inflammation/
Other
163 stars 395 forks source link

Suggestions for episode 3 #516

Open MadeleineGastonguay opened 3 years ago

MadeleineGastonguay commented 3 years ago

In Analyzing Multiple Data Sets, several downsides of writing individual print statements are listed:

  1. It doesn’t scale: if we want to print the elements in a vector that’s hundreds long, we’d be better off just typing them in.
  2. It’s fragile: if we give it a longer vector, it only prints part of the data, and if we give it a shorter input, it returns NA values because we’re asking for elements that don’t exist!

As I was preparing for the live demo, I kept making typos when writing each print statement, which I think would be a great addition to the list of reasons to use a for loop. Making typos is a very relatable downside, and I think it would help drive home why for loops are useful.

In addition, the lesson mentions the length() function after showing that "a loop variable is just a variable that’s being used to record progress in a loop". When I was working through the lesson, this seemed out of order, because at that point we have moved on from the example where a for loop is used to repeatedly update the value of a variable. Moving the discussion of the length() function to immediately follow the vowels example will create a more organized lesson, and appease more experienced R users who may be thinking "why not just use length()?" a that moment.

HaoZeke commented 3 years ago

Hi @MadeleineGastonguay, thanks so much for taking time to bring this up! I think your suggestions are fantastic. Would you be willing to make a PR with the changes so we can discuss this further?