Description Usage Arguments Details Value See Also Examples
Creates variables in the workspace corresponding to the elements of a list
1 | importList(x, ask = TRUE)
|
x |
List to be imported |
ask |
Should R ask the user to confirm the new variables before creating them? (default is |
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.
Invisibly returns 0 if the user chooses not to import the
variables, otherwise invisibly returns 1.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # 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 )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.