How to iterate through hash items, in an R environment?

后端 未结 2 679
無奈伤痛
無奈伤痛 2021-02-03 13:27

I\'m trying to find a way to use a hash map in R, and after some searching I get the R-environment. But how can I iterate through all the items in an environment ? When I run th

2条回答
  •  耶瑟儿~
    2021-02-03 13:42

    The use of "$" inside a function where it is desired to interpret the input is a common source of programming error. Use instead the form object[[value]] (without the quotes.)

    for (v in ls(map)) {
        print(map[[v]])
    }
    

提交回复
热议问题