Is there a straightforward way to turn the functions of a .RData file into a normal code file (.R)?
3 Answers
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
.
-
Great update Joshua. I updated my post to include your solution as well. r-statistics.com/2010/09/… Oct 2, 2010 at 7:07
This recent blog post addresses a basically the same problem:
There's another solution from another post using sink
sink(file="Function.R")
Function # The object
sink()