[STATSGRASS] R-GRASS scripting question
Thomas Adams
Thomas.Adams at noaa.gov
Fri Jan 23 10:17:24 EST 2004
Roger & Edzer,
Thanks for your help! That did the trick.
Regards,
Tom
Roger Bivand wrote:
>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
>>
>>
>>
>>
>
>
>
--
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177
EMAIL: thomas.adams at noaa.gov
VOICE: 937-383-0528
FAX: 937-383-0033
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-stats/attachments/20040123/af19068a/attachment.html
More information about the grass-stats
mailing list