[STATSGRASS] R-GRASS scripting question

Roger Bivand Roger.Bivand at nhh.no
Fri Jan 23 03:20:38 EST 2004


On Fri, 23 Jan 2004, Edzer J. Pebesma wrote:

> 
> 
> Thomas Adams wrote:
> 
> > Roger (or anyone else),
> >
> > I am at an impasse attempting to write an R script to call from within 
> > GRASS. Attached is a code fragment. Basically, I can not get beyond:
> >
> > summary(bias$mapname)
> 
> You want the value of mapname to be evaluated: the content is not in
> bias$mapname but bias$something, with something the value of the
> variable mapname.
> 
> Try:
> 
> summary(bias[[eval(mapname)]]

Yes, this is right. There may be a short cut, if you know definitely for 
example that there is just one raster in the bias list. Then you access it 
by number, for example:

summary(bias[[1]])

The same would apply if there were more, but then it would be easier to 
get mixed up.

> a <- list(a=NA, b=Inf)
> a
$a
[1] NA

$b
[1] Inf

> a$a
[1] NA
> a[[1]]
[1] NA
> a[["a"]]
[1] NA
> an <- "a"
> a$an
NULL

(no such element in list)

> a[[eval(an)]]
[1] NA

Roger

> --
> Edzer
> 
> 

-- 
Roger Bivand
Econonic Geography Section, Department of Economics, Norwegian School of 
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, 
Norway, voice: +47-55959355, fax: +47-55959393; Roger.Bivand at nhh.no





More information about the grass-stats mailing list