tags:

views:

63

answers:

1

Do I need to initialize each level of a multi-level list in R?

l=list()
l[["top"]]=list()
l[["top"]][["mid"]]=list()
l[["top"]][["mid"]][["low_key_1"]]="key_1_val"

or is possible to apply some auto-initialization like on perl?

+3  A: 

You need to initialize each level, but you can do it with one command.

> list(top=list(mid=list(low_key_1="key_1_val")))
$top
$top$mid
$top$mid$low_key_1
[1] "key_1_val"
Joshua Ulrich