attachLocally.list
From R.utils v1.32.4
by Henrik Bengtsson
Assigns an objects elements locally
Assigns an objects elements locally.
- Keywords
- methods, utilities, programming
Usage
## S3 method for class 'list':
attachLocally(object, fields=NULL, excludeFields=NULL, overwrite=TRUE,
envir=parent.frame(), ...)
Arguments
- object
- An object with named elements such as an
environment
, alist
, or adata.frame
. - fields
- A
character
vector
specifying elements to be copied. IfNULL
, all elements are considered. - excludeFields
- A
character
vector
specifying elements not to be copied. This has higher priority thanfields
. - overwrite
- If
FALSE
, fields that already exists will not be copied. - envir
- The
environment
where elements are copied to. - ...
- Not used.
Value
See Also
attachLocally()
of class Object.
attach
().
Examples
foo <- function(object) {
cat("Local objects in foo():
")
print(ls())
attachLocally(object)
cat("Local objects in foo():
")
print(ls())
for (name in ls()) {
cat("Object '", name, "':
", 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)
Community examples
Looks like there are no examples yet.