Curt Seeliger
2012-Sep-27 00:25 UTC
[R] Is there a way to source from a specific Git repository without hardcoding the location everywhere?
Folks,
A small group of us are working together to develop a set of R functions
to support data management and analysis using Eclipse/StatET in a Windows
environment. We are using Git/EGit for version control. We work within
our own repository and occasionally push to a common remote location.
I'd like to have the code source files from the 'local' git
repository
without modification, where 'local' could mean c:\yada\ for one person,
m:\my documents\wetlands\ for another, and l:\foo\bar\sharedRemote\wet\ to
another user.
The chdir argument to source() has been suggested for similar questions,
but I have not been able to figure out how this helps without hardcoding
the location in some manner.
One option is for each repository to have an untracked file which sets the
local working directory before sourcing another file that actually sources
the function definitions. This file (projectStart.r below) would be read
into the R session prior to use, at least during development.
projectStart.r # untracked
setwd("c:\yada\") # or
setwd("L:\foo\bar\sharedRemote\wet\")
-- this is the only difference among repository locations.
source("projectStart2.r")
projectStart2.r # tracked
source("func1.r")
source("func2.r")
source("func3.r")
...
func1.r # tracked
func2.r # tracked
func3.r # tracked
...
Is there an easier or better accepted method?
Thank you for your time,
cur
--
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
seeliger.curt@epa.gov
541/754-4638
[[alternative HTML version deleted]]
Duncan Murdoch
2012-Sep-27 00:35 UTC
[R] Is there a way to source from a specific Git repository without hardcoding the location everywhere?
On 12-09-26 8:25 PM, Curt Seeliger wrote:> Folks, > > A small group of us are working together to develop a set of R functions > to support data management and analysis using Eclipse/StatET in a Windows > environment. We are using Git/EGit for version control. We work within > our own repository and occasionally push to a common remote location. > > I'd like to have the code source files from the 'local' git repository > without modification, where 'local' could mean c:\yada\ for one person, > m:\my documents\wetlands\ for another, and l:\foo\bar\sharedRemote\wet\ to > another user. > > The chdir argument to source() has been suggested for similar questions, > but I have not been able to figure out how this helps without hardcoding > the location in some manner. > > One option is for each repository to have an untracked file which sets the > local working directory before sourcing another file that actually sources > the function definitions. This file (projectStart.r below) would be read > into the R session prior to use, at least during development. > > projectStart.r # untracked > setwd("c:\yada\") # or setwd("L:\foo\bar\sharedRemote\wet\") > -- this is the only difference among repository locations. > source("projectStart2.r") > > projectStart2.r # tracked > source("func1.r") > source("func2.r") > source("func3.r") > ... > > func1.r # tracked > > func2.r # tracked > > func3.r # tracked > > ... > > Is there an easier or better accepted method?Yes. Use library(myProject) where myProject is a package containing all the scripts, written as functions. Duncan Murdoch