This is a straightforward way to add items to an R List:
# create an empty list:small_list = list()# now put some objects in it:small_list$k1 = "v1"small_list$k2 = "v2"small_list$k3 = 1:10# retrieve them the same way:small_list$k1# returns "v1"# "index" notation works as well:small_list["k2"]
Or programmatically:
kx = paste(LETTERS[1:5], 1:5, sep="")vx = runif(5)lx = list()cn = 1for (itm in kx) { lx[itm] = vx[cn]; cn = cn + 1 }print(length(lx))# returns 5