[R-sig-Geo] spgrass6: execGRASS: make the output of the command an R object.

Roger Bivand Roger.Bivand at nhh.no
Mon May 20 19:38:47 CEST 2013


On Mon, 20 May 2013, Paulo van Breugel wrote:

> Hi
>
> In older version of the execGRASS function of spgrass6, setting the option
> intern=TRUE would make the output of the grass command a R object.
>
> Now, when I run execGRASS with the intern=TRUE, like the statement below,
> the output is not written to the R object.
>
> a <- execGRASS("r.univar", flags="g", map=distmod, separator=";",
> intern=TRUE)

With GRASS 6.4.2:

a <- execGRASS("r.univar", flags = "g", map = "elevation.dem", intern = 
TRUE)

works as before. Adding the fs= parameter causes the failure. You are 
using GRASS 7, in which fs= is separator=. In:

raster/r.univar/r.univar_main.c

only \\t, tab, space, and comma are defined as such, others seem to be 
accepted, but ";" is not. I think that the parameter is unused anyway in 
script-style output, but setting fs=";" certainly causes trouble.

Try without that parameter. Your observed difference in behaviour is not 
intended from the R side, and is caused by odd behaviour and interaction 
between parameters on the GRASS side in this GRASS module for your 
parameter settings. Other GRASS modules, and r.univar with different fs= 
settings, work as expected on Unix platforms, but under Windows, legacy 
execution is enforced anyway.

Hope this clarifies,

Roger

>
> The object 'a' is created, but it is empty (character(0)). However, when I
> set legacyExec=TRUE (like below), the object 'a' is created with the grass
> r.univar output.
>
> a <- execGRASS("r.univar", flags="g", map=distmod, separator=";",
> legacyExec=TRUE, intern=TRUE)
>
> Is this the intended behaviour (i.e., did I miss something in the help
> file)?
>
> I am running R version 3.0.1 (2013-05-16), on Ubuntu 13.04 64-bit
>
> Paulo
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
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 R-sig-Geo mailing list