Writing Functions

2024-03-20

We have read

Writing Functions

Why do we need functions?

  • Re-usability

  • Readability

  • Maintainability

Writing functions

  • 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_)

Writing functions

Next Time

  • version control

  • 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.

Homework 6

  • 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

Homework 6

  • print() function doesn’t have a return value

  • Pay attention to the data type