I have some functions in separate R script files that are useful for several different RStudio projects I am working on. Is there a preferred way to use these functions across the projects? Duplicating the files in each project seems stupid and violates standard coding. For reproducibility, I'd like to have access to the exact version of the fxn I used for each project. I suspect over time these functions will slowly morph which might create some problems.
It seems like I could:
- Create soft links from one project directory to another. Using Git with this seems odd, though. I suppose the working project could Git commit the currently used version of the function. I'd have to return to the home project for the fxns and commit over there, too, at some point. Maybe this works. It just seems odd have one fxn stored in two different Git repositories.
- Source() the fxns from their home project. If I need to make changes, I'd just switch projects, fix them, and go back to my working project. This seems like I can't save them in a Git repository for my working project, however.
- Creating a package sounds slick, but I've never done this and seems like a lot of work. I suppose this also might suffer from reproducibility because I won't have a Git commit for the exact version of the function that I used.
Maybe 1 is the right way to go after thinking about this.
What am I missing?