0

My team has dozens of functions living in several different R script files.

We have realized the we would like to move some of these functions from, say, R file A to R file B and other functions into a not-yet-existing R file C.

Is anybody aware of any tools or packages that can facilitate the parsing and rearranging?

I'm hoping not to re-invent the wheel.

Perhaps in devtools?

Atticus29
  • 4,190
  • 18
  • 47
  • 84
  • 3
    Have you thought about packaging them into a library for your team to use? – SymbolixAU Nov 03 '16 at 03:49
  • @SymbolixAU yes! That's one of the reasons we're hoping to get it all organized! – Atticus29 Nov 03 '16 at 03:56
  • 3
    This question seems a bit too broad or opinion based to be a good fit here. Plus questions for tool recommendations are considered off topic. You really just need help cut-and-pasting functions? What's the technical challenge here and how exactly would a tool be helpful? What are the input and outputs you expect. A [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) may make it easier to help you. – MrFlick Nov 03 '16 at 04:28

1 Answers1

1

Suppose all my functions are in file.r,

a <- function(x) x+1
b <- function(x) x+2

I can load them in a fresh session,

source("file.r")

and output them in new files,

lapply(c("a", "b"), function(name) dump(name, file=paste0(name,".r")))

(here creating two files, a.r and b.r, but obviously you can arrange them differently.

baptiste
  • 75,767
  • 19
  • 198
  • 294