字典初始化

数组和集合 / 字典

# Empty dictionary: a named list
d1 <- list()

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

# A new list: d4 stays as it was
d5 <- c(d4, three = 3)

# From two vectors
numbers <- 1:3
words <- c("one", "two", "three")
d7 <- setNames(as.list(words), numbers)

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