Writing Your Own Tools
TRUE.ifelse() is a vectorized if-else.function(), saved as objects.return()).What will the following code return?
I could generalize with a for-loop.
[1] 3 7
colSums() instead?

Many individual functions = wrench set
Custom function = socket wrench set.
function()c_to_f() in your environmentreturn())A function is a like a mill: arguments go in, return value comes out (flour). The hidden machinery does the work.
Question: What will the following code return?
[1] 1 2
[1] 2 1
Task: return a numeric vector with the result of rolling a fair six-sided die.
Task: return a numeric vector with the result of rolling a fair six-sided die.
Question: Modify this function so it can
02:00
Task: return a numeric vector with the result of rolling a fair six-sided die.
Question: Modify this function so it can
Task: return a numeric vector with the result of rolling a fair six-sided die.
Question: Modify this function so it can
Write a function called course_grade() that takes assignment scores as inputs as outputs your current grade in the course.
02:30
What if the weighting scheme were different?
Add flexibility through arguments.
What if we have no final_exam grade yet?
Save typing and head off errors by setting defaults.
How else can we generalize this function for other policies?
function(), saved as objects.return()).