Turning RData file into script files

前端 未结 3 2061
甜味超标
甜味超标 2020-12-29 14:23

Is there a straightforward way to turn the functions of a .RData file into a normal code file (.R)?

相关标签:
3条回答
  • 2020-12-29 14:44

    This recent blog post addresses a basically the same problem:

    http://www.r-statistics.com/2010/09/dumping-functions-from-the-global-environment-into-an-r-script-file/

    0 讨论(0)
  • 2020-12-29 14:47

    There's another solution from another post using sink

    sink(file="Function.R")
    Function # The object
    sink()
    
    0 讨论(0)
  • 2020-12-29 14:55

    Check out ?dump. For example:

    newEnv <- new.env()
    load("myFunctions.Rdata", newEnv)
    dump(c(lsf.str(newEnv)), file="normalCodeFile.R", envir=newEnv)
    

    You may also be interested in ?prompt (which creates documentation files for objects) and / or ?package.skeleton.

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