How can I call the freshest implementation of an R function during package development?

后端 未结 1 543
梦谈多话
梦谈多话 2021-01-27 14:26

Setup:

  • I\'m editting the body of a function foo.bar()in my own package MyPkg.
  • I launch an R session in the root of the package (
相关标签:
1条回答
  • 2021-01-27 14:56

    You can use load_all() from devtools which loads a package that's in development and allows you to use it (e.g. its functions) as if it was installed and loaded.

    If your current working directory is the root of your package, just type

    devtools::load_all()
    

    If the root is not in your current working directory, pass the absolute path to the root as an argument:

    devtools::load_all('/absolute/path/to/MyPkg')
    

    To remove functions that you have defined in your global environment, use rm(), e.g. rm(foo.bar)

    0 讨论(0)
提交回复
热议问题