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

importList

Import a list


Description

Creates variables in the workspace corresponding to the elements of a list

Usage

importList(x, ask = TRUE)

Arguments

x

List to be imported

ask

Should R ask the user to confirm the new variables before creating them? (default is TRUE)

Details

The importList function creates variables in the parent environment (generally the global workspace) corresponding to each of the elements of the list object x. If the names of these elements do not correspond to legitimate variables names they are converted using the make.names functions to valid variables names.

Value

Invisibly returns 0 if the user chooses not to import the variables, otherwise invisibly returns 1.

Warning

This package is under development, and has been released only due to teaching constraints. Until this notice disappears from the help files, you should assume that everything in the package is subject to change. Backwards compatibility is NOT guaranteed. Functions may be deleted in future versions and new syntax may be inconsistent with earlier versions. For the moment at least, this package should be treated with extreme caution.

Author(s)

Daniel Navarro

See Also

Examples

# data set organised into two groups
data <- c(1,2,3,4,5)
group <- c("group A","group A","group B","group B","group B")

# the split function creates a list with two elements
# named "group A" and "group B", each containing the 
# data for the respective groups
data.list <- split( data, group )

# The data.list variable looks like this:

#   $`group A`
#   [1] 1 2
#
#   $`group B`
#   [1] 3 4 5

# importing the list with the default value of ask = TRUE will
# cause R to wait on the user's approval. Typing this:

#   importList( data.list )

# would produce the following output:

#   Names of variables to be created:
#   [1] "group.A" "group.B"
#   Create these variables? [y/n] 

# If the user then types y, the new variables are created.

# this version will silently import the variables.
importList( x = data.list, ask = FALSE )

lsr

Companion to "Learning Statistics with R"

v0.5
GPL-3
Authors
Daniel Navarro
Initial release
2015-03-01

We don't support your browser anymore

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