简体   繁体   中英

Multi-level lists in R

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?

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM