[R] Is there a way to source from a specific Git repository without hardcoding the location everywhere?

Duncan Murdoch murdoch.duncan at gmail.com
Thu Sep 27 11:26:46 CEST 2012


On 12-09-27 3:31 AM, Hadley Wickham wrote:
>>>> 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.
>>>> ...
>>>
>>> Yes.  Use
>>>
>>> library(myProject)
>>>
>>> where myProject is a package containing all the scripts, written as
>>> functions.
>>
>> Yes, the eventual fate of these functions is expected to be a package. I'd
>> like the pushed/pulled code to be runable as is without an intermediate
>> step of package creation or gsub()ing hardcoded paths.
>
> Also, something that Duncan was probably thinking but didn't mention,
> is that creating a package is really really easy - all you need to do
> is put your R files in a directory called R and create a description
> file that says what the package does, who's allowed to use it (the
> license), who to contact if there are problems (author/maintainer) and
> what other packages it requires (depends/imports).

I would usually do more than that:  I find the R documentation system 
helpful even when I'm the only user of a package (and there are the 
prompt* functions for quickly creating it, as well as package.skeleton 
to set things up at the beginning).  Vignettes are a great way to 
organize and document things that are done via scripts.  And if you want 
to include compiled C or C++ or Fortran code, packages are drastically 
easier to manage than other approaches.

Duncan Murdoch




More information about the R-help mailing list