remi-daigle / bioeconomic_MPA

BEST-MPA = Bio-Economic Selection Toolbox for Marine Protected Areas
http://remi-daigle.github.io/bioeconomic_MPA
MIT License
0 stars 4 forks source link

some thoughts #8

Open sckott opened 8 years ago

sckott commented 8 years ago

you asked on twitter how could put things into functions

The user_input file sets a bunch of variables to be used - these could be instead R options, e..g., a function for setting options like set_options(time = x, replicates = 100, ...) and set the options within that fxn - OR if each options pertains only to some code parts, then the functions created for those things could accept these options as parameters

The master file - what that file does could be a function, and instead of source() -ing each part, those are instead functions, e.g., replace source("reproduct_output.R") with a function call reproduct_output(...) with whatever parameters it should take

having said all this, I realize this would be a lot of work - Though you do get all the benefits of an R pkg structure, being able to easily include documentation, unit tests for your code, etc.

remi-daigle commented 8 years ago

It took me way too long to get around to this, but I'm finally starting to rebuild this as a package. However, it seemed easier to start a new repo and 'start fresh' as a package. I'm also moving from and individual based model to an age structured spatially explicit model to speed things up (to make it more usable). I'm going to keep the user_input.R and master while I rebuild the basic functions and then I'll make master a giant wrapper function that uses a lot of the parameters from user_input as arguments.