Section 8 List
8.1 Function
Example vector:
x <- c(1:20); y <- rep(c('R1','R2','R3'), each=4); z <- rep(c(T,F), length=4)
Function | Explanation | Example |
---|---|---|
list |
Create a list | y <- list(Age=x, Region=y, Epi=z) |
as.list |
Coerce into a list | as.list(y) |
is.list |
Check if its argument is a list | is.list(y) |
length |
Length of a list | length(y) |
attributes |
Attributes of a list | attributes(y) |
List
8.2 Example
?list
<- c(1:20)
x <- rep(c('R1','R2','R3'), each=4)
y <- rep(c(T,F), length=4)
z
<- list(Age=x, Region=y, Epi=z)
y
y
is.list(y)
names(y)
attributes(y)
str(y)
# Create an empty list
<- vector('list', length=3)
z names(z) <- c('Here','There','Everywhere')
z
Note: Data frames are special type of list with every element of the list of equal length.