字典初始化

数组和集合 / 字典

# 空字典:命名列表
d1 <- list()

d4 <- list(one = 1, two = 2)

# 新的列表:d4 保持原样
d5 <- c(d4, three = 3)

# 由两个向量创建
numbers <- 1:3
words <- c("one", "two", "three")
d7 <- setNames(as.list(words), numbers)

str(d1)
str(d4)
str(d5)
str(d7)