2024-03-20
Why do we need functions?
Re-usability
Readability
Maintainability
Syntax
R: function_name <- function(params){ }
Python: def(params):
parameter vs argument
passing in more than one arguments
follow the order of parameters
(x_, y_) ->func(x, y)
specify by parameters
func(x=x_, y = y_)
Input validation
Handle exceptions
data type
invalid data
stopifnot()
and try...except...
Scope
Lexical scope: the area that is between the braces/ indented region
“Rewrite”
Before next week: Sign up for Github Classroom
Seminar of interest: Dr. Heike Hofmann will talk about the practical side of building data processing pipelines. Hardin 901, 11:30 - 12:20, with lunch afterwards.
Earn 2 points of extra credit on a reading quiz.
Download and save Homework6 raw content
Click the link
Copy the raw content
Save to a Quarto file under Source mode
Name the file as 06-Lastname-Firstname.qmd
Submit in .qmd file
print()
function doesn’t have a return value
Pay attention to the data type