Description Usage Details Examples
Convenience functions to get the system function, its attributes or environment.
1 2 3 4 | THIS ()
THAT ()
THEN ()
|
These functions are wrappers for standard R functions.
THIS returns the system function, that is, the current function that's being called.
THAT returns the system function's attributes and THEN returns the system function's environment.
Note that THAT and THEN are contractions of TH(is) AT(tributes) and TH(is) (EN)vironment.
They need to be evaluated inside the function where they're defined.
(This is important, please refer to the examples).
It may be useful to combine the with/THAT functions.
(Also, please refer to the examples).
In general, the THEN function isn't necessary.
(Because R uses lexical scoping, and functions can be called with standard syntax, using objects contained in their environments).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #good
#(THIS evaluated *before* do.something)
f <- function (x)
{ this <- THIS ()
do.something (this, x)
}
#bad
#(THIS evaluated *in* do.something)
f <- function (x)
do.something (THIS (), x)
#combined with/THAT example
f <- function (x)
{ . <- THAT ()
with (.,
do.something (attr.1, attr.2, x) )
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.