[R] sourcing a linux file with "system"

David Kirkby david.kirkby at onetel.net
Sat Feb 26 13:34:50 CET 2011


On 26 February 2011 11:00,  <james.foadi at diamond.ac.uk> wrote:
> Dear R community,
> I would like to source a file in my linux system to set a few environment variables.
> I have tried:
>
>> system("source /home/james/build//ccp4-6.1.13/include/ccp4.setup")
>
> and got:
>
> sh: source: not found

Someone has been writing unportable code. Instead change it to

system(". /home/james/build//ccp4-6.1.13/include/ccp4.setup")

A "dot" will source a file, in a manner which avoids the need of a
command that is not defined by POSIX.

Dave



More information about the R-help mailing list