Functions
- Function accepts N number of inputs and provides one output
- Functions works like a black box
- Function arguments matching : by position or by name
- Function arguments can have defaults
vec <-c(10,30,40,50,20)
sd(vec)
vec <-c(10,30,40,50,20,NA)
sd(vec)
sd(x=vec,na.rm=TRUE) #by value
sd(vec,TRUE) #by position
sd()
|
- What is the default value of na.rm argument? FALSE
- How to see arguments of a function?
- Exercise 1: create function with one mandatory argument
- Method 1:
- Method 2:
- Exercise 2: create function with two mandatory arguments
- Exercise 3: create function with one mandatory arguments and one optional argument
No comments:
Post a Comment