Working with dictionaries/lists in R

后端 未结 7 1626
说谎
说谎 2020-12-07 09:14

I have trivial question: I couldn\'t find a dictionary data structure in R, so I used list instead (like \"word\"->number) So, right now I have problem how to get the list o

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 09:50

    The package hash is now available: https://cran.r-project.org/web/packages/hash/hash.pdf

    Examples

    h <- hash( keys=letters, values=1:26 )
    h <- hash( letters, 1:26 )
    h$a
    # [1] 1
    h$foo <- "bar"
    h[ "foo" ]
    #  containing 1 key-value pair(s).
    #   foo : bar
    h[[ "foo" ]]
    # [1] "bar"
    

提交回复
热议问题