-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
callout defining function #46
Conversation
p.s., I also wrote this (per the issue), but I don't actually think its an improvement over just getting into the example: Functions take the form: function_name <- function( parameters ) function_body where:
You invoke a function by entering its name followed by the call operator, a pair of parentheses: "()". If the function takes parameters, they go inside the parentheses. R will then execute the function's body, expression by expression. If you assign the result of the function to a variable:
then, when the function finishes executing, whatever it returns will be stored in that variable. By default, R functions return the last evaluated expression. Many functions use the return keyword to send a specific object back to the caller. |
I really like this Callout! I made a few line notes. I have pretty mixed feelings about this "imitation syntax" approach that I've seen sometimes:
Because it doesn't really resemble actual syntax (ie no |
I think its a really good idea to have this callout: I'd even suggest putting it in the very first topic after the first instance where an instructor calls a function. I'm also not a fan of the "imitation syntax". Novices seem to struggle with pseudocode, its too abstract for them to understand, especially since they've been hammered with lots of new concepts. |
I think showing the general form of a function is pretty important. But I agree pseudocode can be confusing for beginners. How about something like this? It's still very general, but at least the code would run. Functions take the form: function_name <- function( input ) {
result <- input + 1 # The body of the function.
return( result ) # Optional return statement
} |
I like it! |
I really prefer this. Now we have a function that is instructive for beginners, while not being distressing to people who already write functions. I will resolve whatever conflicts (!) we have here and merge this. |
Minor correction: Author of "Thinking Physics"
To address Issue #26