[GRASS-stats] R library not found in batch mode

Roger Bivand Roger.Bivand at nhh.no
Tue Mar 2 14:36:48 EST 2010


On Tue, 2 Mar 2010, ghislain v. wrote:

> Dear GRASS and R users,
>
> I try to use R within GRASS in batch mode:
>
> - I have a first file Script.sh which includes:
>
> #!/bin/sh
> export GRASS_BATCH_JOB=/home/ghislain/my_grassjob.sh
> grass64 /home/ghislain/grassdata/Geo/PERMANENT
>
> - A second file my_grassjob.sh which includes:
>
> #!/bin/sh
> R CMD BATCH /home/ghislain/ScriptRwithinGRASS.r
>
> - And a third file (the R script ScriptRwithinGRASS.r) containing:
>
> library(GRASS)
> library(spgrass6)
> library(sp)
> system("g.region -p")
> ...
> ... other commands
>
> When, I launch sh Script.sh, it opens GRASS and R correctly but the
> libraries cannot be found:
>
>> library(GRASS)
> Erreur dans library(GRASS) : aucun package nommé 'GRASS' n'est trouvé
> Exécution arrêtée
>
> Whereas when I use in a terminal the following commands:
>
> grass64 /home/ghislain/grassdata/Geo/PERMANENT
> R
> library(GRASS)
>
> the GRASS library is found.
>
> Does someone have an explication to overcome this problem.

Set the environment variable R_LIBS to where you keep your packages. R in 
batch mode does not some start-up files.

Roger

PS. Only use GRASS if you have GRASS 5, and never with spgrass6, there is 
no point at all (no harm, just irrelevant).

>
> Thanks for your help.
>
> Ghislain
> _______________________________________________
> grass-stats mailing list
> grass-stats at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-stats
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no


More information about the grass-stats mailing list