attachLocally.list | R Documentation |
Assigns an objects elements locally.
## S3 method for class 'list'
attachLocally(object, fields=NULL, excludeFields=NULL, overwrite=TRUE,
envir=parent.frame(), ...)
object |
An object with named elements such as an |
fields |
A |
excludeFields |
A |
overwrite |
If |
envir |
The |
... |
Not used. |
Returns (invisibly) a character
vector
of the fields copied.
Henrik Bengtsson
attachLocally()
of class Object.
attach
().
foo <- function(object) {
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"
l <- list(a=1:10, msg="Hello world", df=data.frame(a=NA, b=2))
foo(l)
print(a)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.