[STATSGRASS] raster cross-stats
Roger Bivand
Roger.Bivand at nhh.no
Fri Dec 14 04:15:14 EST 2001
On Thu, 13 Dec 2001, Markus Neteler wrote:
> Sorry for a FAQ, but (due to my current traveling with temporal
> internet access) how can I specify a parameter such as
> $1 in shell scripts?
> I want to add parameters to the scripts which are visible within
> R BATCH. If you could point me to a online document
> I would be glad.
>
If $1 is a shell variable, then it is visible - here are some lines from
the r.statistics.R shell script:
> > layer=$1
> >
> > method=$2
> > R --vanilla --quiet --slave << EOF
> > library(GRASS)
> > print($method(rast.get(gmeta(), "$layer")[[1]]))
> > EOF
> >
If you need to use $ as an R symbol - maps$elev say - then normal shell
script rules should apply? Escape with a backslash? map\$elev I guess?
R CMD BATCH wants an input file, doesn't it (haven't used it
myself) rather than redirection from stdin as above? Then you would echo
and/or cat the created script to an infile.R, then run the batch. It's
also possible to write a generic script for R using connections - which
are pretty powerful. Reading r.out.bin files through connections is on my
todo list to replace text transfer for interpreted mode.
I don't think I've helped - I'm a bit unsure about your specific needs?
Roger
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
and: Department of Geography and Regional Development, University of
Gdansk, al. Mar. J. Pilsudskiego 46, PL-81 378 Gdynia, Poland.
More information about the grass-stats
mailing list