R Function
To define a function
jiggle <- function(x) {
x = x + rnorm(1, sd=.1)
return(x)
}
jiggle(5)
The return function is not necessary; it can be any statement that returns a result. For example
f <- function(x) { x*x }
f(4)
To define a function
jiggle <- function(x) {
x = x + rnorm(1, sd=.1)
return(x)
}
jiggle(5)
The return function is not necessary; it can be any statement that returns a result. For example
f <- function(x) { x*x }
f(4)