Open martinherrerias opened 1 year ago
On the point about the return() statement (not sure if this deserves its own issue, but it fits here nicely):
Further down it is explained, that "R will automatically return the results of whatever command is executed on the last line of the function" (https://swcarpentry.github.io/r-novice-gapminder/10-functions.html#more-on-combining-functions). I think this statement is misleading, since you could think that in the example above you can just remove the return() line and it works the same. But you would also need to omit the "gdp<-" in the line before.
So I would suggest to rather include to equivalent examples, one with a return() statement, and one without.
Apart from that I fully agree with the issues raised by @martinherrerias.
As a PhD student in Europe with Asian heritage, I especially agree with this issue. Fahrenheit is rarely used in Asia nor in Europe, not to mention Kelvin (more useful in science AFAIK). Converting between them makes things even more complex. Since Carpentries aims to relieve cognitive load, I strongly believe that there are better choices for this episode. Celsius_to_Kelvin seems to be a more suitable choice to me. After all, the goal is only to learn the usage and structure of Function in R.
I agree with the comments here about cognitive complexity, but changing this out would represent a pretty substantial overhaul of the whole lesson. What do you think @matthieu-bruneaux @skanwal?
How could the content be improved?
Ch. 10. Functions Explained starts with examples of functions (
fahr_to_kelvin
andkelvin_to_celsius
) that are clunky to type (draw attention away from the matter) and not rich enough to explain general function syntax and scoping. Then, halfway down the lesson, and while working on a more complicated function, there's suddenly: multiple-arguments, default values, the fact thatreturn()
can be left out, and scoping rules.I'd suggest:
return()
early on, on those simple functionsR
(a mistyped name can be found in a parent environment), and is at the same time one of the main arguments for using functions, so it should take more than a note.Which part of the content does your suggestion apply to?
https://swcarpentry.github.io/r-novice-gapminder/10-functions.html