Packages
search()
is used to show which packages are currently running
library()
is used to show all available & installed packages
install.packages('ISwR')
is used to install a given package
library('ISwR')
is used to load installed packages into R
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)