### Replacement functions : v <- 1:5 names(v) <- LETTERS[1:5] v <- 1:5 names(v) <- c("Hans", "Heiri") v `names<-` get("names<-") # here equivalent to the use `...` "[<-" <- function(){} find("[<-") # in two places .. rm("[<-") `[<-.factor` ## the "factor" method of the `[<-` generic function `[.factor` ## This is the "factor" method of the `[` generic function ### An R function is made of three parts ### 1) formals() : The argument list ### 2) body() : The function body ### 3) environment(): The environment in which the function has been defined str ( formals(abline) ) ?body ?formals ## there is a replacement function def.u <- formals(abline)\$untf def.u deff <- formals(formals)[["fun"]] deff class(deff) ## missing() allows to check if an argument has been specified ## --------- in the actual call: tt <- function(x, ab=TRUE) { cat("missing(x):", missing(x), "miss.(ab):", missing(ab),"\n") formals() } tt(1) tt(1, TRUE) tt() ## the formals arguments of tt() sin # formal argument 'x' sin(pi) # actual argument 'pi' --- is matched to the formal: ## Something like 'x <- pi' happens implicitly. ## sin is *Primitive* function -- these are made to be very fast in R ## by ``diving into C-level'' of R immediately. ## ==> They are the exeptions: all three parts are empty formals(sin) ## NULL, ditto for the body body (sin) environment(sin)