hello_world <- function() { print("Hello, World!") }
hello_world <- function() { return("Hello, World!") }
Default Param
two_fer <- function(input=NULL) {}
sprintf
for string interpolation
two_fer <- function(input) { if (is.null(input)) { print("One for you, one for me.") } else { sprintf("One for %s, one for me.", input) } }
Returns a character vector containing the formatted combination of text and variable values
Accepts two parameters: first is the format with %
as the target for variable, second is the variable.
leap <- function(year) { if(year %% 400 == 0){ return(TRUE) } else if (year %% 100 == 0){ return(FALSE) } else if (year %% 4 == 0){ return(TRUE) } else { return(FALSE) } }
# Floating Division: 5/2 # 2.5 # Integer Division: 5%/%2 # 2 # Remainder: 5%%2 # 1