October 2011
Beginner to intermediate
400 pages
9h 30m
English
As remarked at several points in this book, the purpose of the R function function() is to create functions. For instance, consider this code:
inc <- function(x) return(x+1)
It instructs R to create a function that adds 1 to its argument and then assigns that function to inc. However, that last step—the assignment—is not always taken. We can simply use the function object created by our call to function() without naming that object. The functions in that context are called anonymous, since they have no name. (That is somewhat misleading, since even nonanonymous functions only have a name in the sense that a variable is pointing to them.)
Anonymous functions can be convenient if they are short one-liners and are called by another ...
Read now
Unlock full access