Christian
Christian

Reputation: 26387

Turning RData file into script files

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

Upvotes: 9

Views: 2207

Answers (3)

DeadlyStorm
DeadlyStorm

Reputation: 1

There's another solution from another post using sink

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

Upvotes: 0

Aaron
Aaron

Reputation: 816

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/

Upvotes: 3

Joshua Ulrich
Joshua Ulrich

Reputation: 176648

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.

Upvotes: 16

Related Questions