How to edit and debug R library sources

前端 未结 3 1669
时光取名叫无心
时光取名叫无心 2020-11-29 02:51

I\'ve included a library called blotter in my R script which has a bug in it. Is there an easy way for me to edit the source to try and debug the issue?

3条回答
  •  眼角桃花
    2020-11-29 03:28

    Such a feature is implemented in the development version of R (Jul 16, 2010):

    A new facility has been added to r-devel for experimenting by authors of packages.

    The idea is to insert modified code from the package source into the running package without re-installing. So one can change, test, change, etc in a quick loop.

    The mechanism is to evaluate some files of source code, returning an environment object which is a snapshot of the code. From this environment, functions and methods can be inserted into the environment of the package in the current session. The insertion uses the trace() mechanism, so the original code can be restored.

    The one-step version is:

    insertSource("mySourceFile.R", package = "myPackage", functions = "foo")

    See this post for further details: Inserting and testing revised functions in a package

提交回复
热议问题