How to create functions in R

1. to create functions in R we have to write function keyword followed by brackets ()opening and closing.

2. then inside curley braces { } opening and closing we have to write the code for the function.

3. then we have to asign this function to a variable to ease of access so that later on when we want to call that function then we have to just type the variable name instead of the function call.

4. is that simple to craete a function in R like in other lanuages we can create.

5. so in the following example we are creating a function rnorm which interprets the mean of the 100.

6. and then lastly we are asigned this function to a variable name called my_function

my_function <- function() { x <- rnorm(100) mean(x)

}

addition <- function(x) {

y <-x+4

}