Great, good to know what is going on a bit better. I tried it out from the
command line with and without quoting the semicolon  separator=;. In both
cases the functions run and return the statistics, but when the semicolon
is not quoted, the statistics are not separated by any separator.

Another function that is affected by the same is r.stats, and there might
be more. So if the suggestion of Rainer could work, great.

I will suggest to the GRASS developers to make it more explicit in the help
file that semicolon should not be used or quoted when used. To be fair, the
help files do mention the separators that can be used, and the semicolon is
not one of them.. but well, just in case, there might be more not reading
the help file careful enough.


On Tue, May 21, 2013 at 10:17 AM, Rainer M. Krug <Rainer@krugs.de> wrote:

> Roger Bivand <Roger.Bivand@nhh.no> writes:
>
> > On Mon, 20 May 2013, Paulo van Breugel wrote:
> >
> >> Great, this is really helpful. You are right, and I should have seen
> from
> >> the help file, that the semicolon is not one of the supported
> separators.
> >> The odd thing is it works when running r.univar from grass directly if I
> >> use the table flag (-t instead of -g). But now I know I shouldn't.
> >
> > With GRASS 7:
> >
> > a <- execGRASS("r.univar", flags = "t", map = "elevation.dem",
> >  separator="; ", intern = TRUE)
> >
> > works, but:
> >
> > a <- execGRASS("r.univar", flags = "t", map = "elevation.dem",
> >   separator=";", intern = TRUE)
> >
> > does not. The problem is that the trailing ";" on the command line to
> > GRASS is also the shell line terminator, so must be protected by
> > quoting:
> >
> > a <- execGRASS("r.univar", flags = "t", map = "elevation.dem",
> >   separator="';'", intern = TRUE)
> >
> > or:
> >
> > a <- execGRASS("r.univar", flags = "t", map = "elevation.dem",
> > separator=shQuote(";"), intern = TRUE)
>
> Following the escaping: I can not think about any problems, if all
> arguments for grass are quoted (OK - I am speaking from the Linux side
> without enough Windows experience with R to know if it works there as
> well). Escaping *all* arguments *automatically* should make
> execGRASS even more stable?
>
> Rainer
>
> >
> > both work.
> >
> > Roger
> >
> >
> >>
> >> Thanks for helping out, much appreciated!
> >>
> >> Paulo
> >>
> >>
> >>
> >>
> >>
> >> On Mon, May 20, 2013 at 7:38 PM, Roger Bivand <Roger.Bivand@nhh.no>
> wrote:
> >>
> >>> 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@r-project.org
> >>>> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo<
> 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@nhh.no
> >>>
> >>>
> >>
> <#secure method=pgpmime mode=sign>
>
> --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
> Biology, UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Stellenbosch University
> South Africa
>
> Tel :       +33 - (0)9 53 10 27 44
> Cell:       +33 - (0)6 85 62 59 98
> Fax :       +33 - (0)9 58 10 27 44
>
> Fax (D):    +49 - (0)3 21 21 25 22 44
>
> email:      Rainer@krugs.de
>
> Skype:      RMkrug
>

	[[alternative HTML version deleted]]

