Transcription of Introduction to the R Language - Functions
{{id}} {{{paragraph}}}
Introduction to the R LanguageFunctionsBiostatistics R LanguageFunctionsFunctions are created using thefunction()directive and arestored as R objects just like anything else. In particular, they are Robjects of class function .f <- function(<arguments>) {## Do something interesting} Functions in R are first class objects , which means that they canbe treated much like any other R object. Importantly, Functions can be passed as arguments to other functionsFunctions can be nested, so that you can define a functioninside of another functionThe return value of a function is the last expression in the functionbody to be R LanguageFunction ArgumentsFunctions havenamed argumentswhich potentially argumentsare the arguments included in thefunction definitionTheformalsfunction returns a list of all the formalarguments of a functionNot every function call in
Argument Matching R functions arguments can be matched positionally or by name. So the following calls to sd are all equivalent > mydata <- rnorm(100)
Domain:
Source:
Link to this page:
Please notify us if you found a problem with this document:
{{id}} {{{paragraph}}}