Turning RData file into script files

假如想象 提交于 2019-11-29 03:03:29

问题


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


回答1:


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.




回答2:


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/




回答3:


There's another solution from another post using sink

sink(file="Function.R")
Function # The object
sink()


来源:https://stackoverflow.com/questions/3835714/turning-rdata-file-into-script-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!