Packages

Making New Functions

name=function(parameter1, parameter2) {
	arguments
}

#example1
add=function(a=2,b=9) {
	a + b
}
add(1,2) -> 3
add(1) -> 10
add() -> 11
add(b=1) -> 3

#example2
test=function(x) {
	if (is.charCter(x)) {
		return(x)
	} else {
		return (x+5)
	}
}
test('x') -> 'x'
test('5') -> '5'
test(5) -> 10
nums = c(1,2,3)
test(nums) -> (6,7,8)