-
-
Notifications
You must be signed in to change notification settings - Fork 537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smoother introduction to functions? #865
Comments
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. |
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
The text was updated successfully, but these errors were encountered: