Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Package Development: Multiple files or Single File

Tags:

r

r-package

I've been poking through a bunch of different packages and I'm noticing that there really isn't a clear and concise method for function storage. Some package authors pack all of them in one file while other authors split them into individual files.

I've read a number of package creation guides but none of them provide specific guidelines or suggestions.

Would love to hear your thoughts on this.

like image 626
Brandon Bertelsen Avatar asked May 28 '11 01:05

Brandon Bertelsen


2 Answers

The best reference I have found on the topic thus far is from Hadley Wickham's R book draft. Quoting from there:

It's up to you how you arrange your functions into files, but I suggest grouping related functions into a single file. My rule of thumb is that if I can't remember which file a function lives in, I probably need to split them up into more files - having one function per file is perfectly reasonable, particularly if the functions are large or have a lot of documentation.

like image 82
diliop Avatar answered Oct 21 '22 01:10

diliop


I use one function per file. It helps me in the developing stage because I can source individual file (CTRL+R+S in Eclipse) and have a changed function handy. I also prefer changing tabs than scrolling up and down a single file. But at the end of the day it probably depends on what you're used to and what tools you use for development.

like image 44
Roman Luštrik Avatar answered Oct 21 '22 02:10

Roman Luštrik