loader {utilitiesR}R Documentation

loads an Rdata file and returns a list of the contents

Description

This function loads an Rdata file and returns a list containing its contents. The advantage is that it doesn't clutter the global workspace.

Usage

  loader(filename, names = NULL)

Arguments

filename

name of the Rdata file

names

optional, character vector of objects in the Rdata file to retrieve (leave out to retrieve everything).

Value

a LIST with names(lst)==names, values being the object from the Rdata file. No entry for those objects in names that were not found in the Rdata file.

See Also

Other library: reload

Examples

# create some data to save
a <- 1
b <- 2
save(a,b,file='ab.rda')
# load them back
obj <- loader('ab.rda')
names(obj) # 'a', 'b'
obj$a      # '1'

# example of looking for particular objects: look for 'a' and 'foo'.
obj <- loader('ab.rda',names=c('a','foo'))
names(obj) # 'a' (foo wasn't found)
obj$a      # 1
obj$foo    # NULL (wasn't found)

# Demonstrate that it doesn't clutter local workspace
rm(list=ls())
a <- 'foobar'
obj <- loader('ab.rda',names='a')
obj$a  # 1
a      # 'foobar'

[Package utilitiesR version 1.8.2 Index]