Writing Functions in R: Part I
I have been learning how to write functions in R. They are core to learning the language instead of just using what other people have written for their purposes. They make tailored manipulations in R easier. I am going to document the function writing system here, step by step so I can progressively write better functions and yet not forget the basics
Basic Syntax
Basic Syntax
NewFunction <- function (input){
answer <- some manipulation with the input
answer
}- NewFunction is the name of the new function.
- function is the R function that creates functions.
- input is the "argument" of a function
- { delimits the beginning of the function
- } delimits the end of the function
- the last statement (in this case, just "answer", returns the answer as the output of the function. I could also have said return(answer).