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

Markus Neteler neteler at osgeo.org
Tue Mar 2 14:38:54 EST 2010


On Tue, Mar 2, 2010 at 8:03 PM, ghislain v. <quenual at gmail.com> 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)

Note that "GRASS" is for GRASS *5* and will likely break things.
( http://cran.r-project.org/web/packages/GRASS/index.html )

> 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

I think that you should avoid to call library(GRASS).


If you take out that line your script may work.

Markus


More information about the grass-stats mailing list