Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

attachLocally.list

Assigns an objects elements locally


Description

Assigns an objects elements locally.

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, a list, or a data.frame.

fields

A character vector specifying elements to be copied. If NULL, all elements are considered.

excludeFields

A character vector specifying elements not to be copied. This has higher priority than fields.

overwrite

If FALSE, fields that already exists will not be copied.

envir

The environment where elements are copied to.

...

Not used.

Value

Returns (invisibly) a character vector of the fields copied.

Author(s)

Henrik Bengtsson

See Also

attachLocally() of class Object. attach().

Examples

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)

R.utils

Various Programming Utilities

v2.10.1
LGPL (>= 2.1)
Authors
Henrik Bengtsson [aut, cre, cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.