Turning RData file into script files
Asked Answered
U

3

9

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

Unasked answered 1/10, 2010 at 0:19 Comment(0)
E
16

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.

Evidential answered 1/10, 2010 at 0:28 Comment(1)
Great update Joshua. I updated my post to include your solution as well. r-statistics.com/2010/09/…Celery
J
3

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/

Jehu answered 1/10, 2010 at 3:47 Comment(0)
R
0

There's another solution from another post using sink

sink(file="Function.R")
Function # The object
sink()
Resource answered 31/7, 2014 at 20:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.