Naming conflicts in R when using attach

前端 未结 2 1196
旧时难觅i
旧时难觅i 2021-01-16 12:28

I feel as if constantly in R, I get weird naming conflicts between attached dataframes and other objects, attaches/detaches not working as expected (just had two copies of t

2条回答
  •  半阙折子戏
    2021-01-16 13:01

    It is better to use a new environment for a series of data. For example, I normally create an e environment with this command.

    e <- new.env()
    

    Then you can access the individuals in the environment with e$your_var.

    The other benefit:

    1. You can use eapply on the element of environment.
    2. ls(e)
    3. rm(list=e)
    4. It is avoid the conflict between your local variable and function variable that you want to create 5 ...

提交回复
热议问题