Why is using assign bad?

后端 未结 3 1690
悲&欢浪女
悲&欢浪女 2020-11-21 23:56

This post (Lazy evaluation in R – is assign affected?) covers some common ground but I am not sure it answers my question.

I stopped using assign when I

3条回答
  •  别跟我提以往
    2020-11-22 00:01

    I'd like to point out that assign is meant to be used with environments.

    From that point of view, the "bad" thing in the example above is using a not quite appropriate data structure (the base environment instead of a list or data.frame, vector, ...).

    Side note: also for environments, the $ and $<- operators work, so in many cases the explicit assign and get isn't necessary there, neither.

提交回复
热议问题