attachLocally.Object | R Documentation |
Attaches an Object locally to an environment. By default, the fields of the Object are attached to the parent frame, that is, the calling environment.
## S3 method for class 'Object' attachLocally(this, private=FALSE, fields=NULL, excludeFields=NULL, overwrite=TRUE, envir=parent.frame(), ...)
private |
If |
fields |
A |
excludeFields |
A |
overwrite |
If |
envir |
The |
... |
Not used. |
Returns (invisibly) a character
vector
of the fields copied.
Henrik Bengtsson
*attach()
For more information see Object
.
foo <- function(object, arg1="some value", ...) { cat("Local objects in foo():\n") print(ls()) attachLocally(object) cat("\nLocal objects in foo():\n") print(ls()) for (name in ls()) { cat("\nObject '", name, "':\n", sep="") print(get(name, inherits=FALSE)) } } a <- "A string" obj <- Object() obj$a <- "Another string" obj$b <- NA foo(obj) print(a)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.