Course Notes
Use this workspace to take notes, store code snippets, and build your own interactive cheatsheet!
Note that the data from the course is not yet added to this workspace. You will need to navigate to the course overview page, download any data you wish to use, and add it to the file browser.
# Import any packages you want to use here
Take Notes
Add notes here about the concepts you've learned and code cells with code you want to keep.
Add your notes here
# Add your code snippets here
NOTES: 05022023
Function arguments can be either "data arguments", or "detail arguments".
Default arguments: Default arguments are detail arguments that have been given "prespecified" values given in advance. They help by making it quicker to use a function, as some arguments might have some values that are much more common than others. For example, when I need to toss a coin, I would like it to be fair, so, in most cases, the probability of heads will be 50%. So, we can prespecify this value in the argument "probability" inside the function signature.
Default arguments can be of any type (numeric, logical, character), with two "special" types, NULL, and categorical. The latter is a character vector, giving different optional values to the argument.
PROSOXI!!! ... (dot-dot-dot) arguments, are used within a function signature to denote that any argument that will be added in the function signature might be used within the function body when other functions (within the body) need extra arguments. For example, mean() contains and na.rm argument (defaults to FALSE). If we use mean() in our function, then we can specify my_function <- function(...){mean(...)}, so the mean function inside the body will take whatever argument the user has added to the function call.