[GRASS-stats] GRASS within R interface issues

Roger Bivand Roger.Bivand at nhh.no
Wed May 2 14:44:57 EDT 2012


On Sat, 28 Apr 2012, Laura S wrote:

> Dear all:
>
>
> I emailed around and others have the same issue of the freezing GRASS 
> console and not being able to run R within GRASS, and many resort to 
> doing GRASS commands within R using execGRASS(). 

You do need to understand what you are doing, I'm afraid.

If you just enter "C:\Program Files\ ... \Rgui.exe" at the MSYS prompt, it 
starts R and does not return until you exit R. If, however, you trat MSYS 
as Unix, and add & after the "C:\Program Files\ ... \Rgui.exe" (only 
tried on XP as this is the Windows version involved here):

"C:\Program Files\ ... \Rgui.exe" &

MSYS will start R within GRASS, and return to its prompt - which I think 
is what you want. In addition, you can run GRASS commands from the GRASS 
GUI, either using the point and click GUI, or typing into the command 
console tab at the bottom of the layer manager, in addition to the 
equivalent execGRASS() in R.

Hope this clarifies,

Roger

>
> I am going to keep searching around for a fix, as I still cannot run R 
> within GRASS on XP. I am trying to figure this out for myself and other 
> collaborators.
>
>
> Cheers,
> Laura
>
>
>
> ________________________________
> From: Laura S <les_ecol at yahoo.com>
> To: "grass-stats at lists.osgeo.org" <grass-stats at lists.osgeo.org> 
> Sent: Monday, April 23, 2012 2:34:40 PM
> Subject: [GRASS-stats] GRASS with R interface issues - running R within GRASS 6.4.2
> 
>
> Dear all:
>
> Do you have any suggestions on this? Thank you.
>
>
> I cannot type in the GRASS GUI with MSYS window and execute commands. It is 
> frozen, and when I open up another GRASS console and type R the console 
> says: "R is not recognizable as an internal or external command, 
> operable program or batch file." 
>
>
> I provide examples below. Roger has been helpful, but I am still unsure if I am missing something, or there is a bug. 
>
>
> I have found bugs in other programs, e.g., WinRhizo, but I am assuming GRASS is working fine. I have been looking for screenshot instructions to better understand my issue, so anyone knows of these posted somewhere, this would be helpful. 
>
>
> Laura
>
>
> On Mon, 23 Apr 2012, Laura S wrote:
>
>> Dear Roger and others:
>> 
>> My apologies if I am not piecing everything together. I think I am almost there; I appreciate your patience.
>> 
>> 
>> This is my current point of confusion, and what I am able to do so far:
>> 
>>
> I. My main point of confusion is that when I type the path into GRASS 
> MSYS, the R console window pops up, and I am unable to type more into 
> the GRASS console. I cannot type GRASS commands in R, so I am unsure 
> where I type the GRASS commands if GRASS console does not let me type 
> more, and the R console does not recognize R commands.
>
> Why should
> it? Simply minimise the R GUI to work in GRASS directly, using the 
> GRASS GUI or from the prompt in MSYS. I doubt very much whether saying 
> d.ask makes sense anyway, as the GRASS display GUI covers that.
>
> It
> is possible to write GRASS commands using execGRASS() from the R 
> console, but since you have had to ask, you will find it easier simply 
> to minimise R and use GRASS directly. Because R is within GRASS, it 
> "sees" the current status of the location.
>
> Hope this clarifies - please change to one of the GRASS lists for further help.
>
> Roger
>
>> 
>> 
>> II. What I can do so far in more detail:
>>
> 1. Within the GRASS 6.4.2RC2 with MSYS, I typed using tab 
> autocompletion: "C:/Program Files/R/R-2.14/bin/i386/Rgui.exe" which 
> causes the RGui to pop up as a second R window. Thus, I am not in GRASS 
> directly anymore I assume, but rather in the RGui. In this GUI, it says 
> the following when I type library(spgrass6): "GRASS GIS Interface loaded
> with GRASS version GRASS 6.4.2RC2exported (2011) and location: 
> demolocation" gmeta6() gisdbase C:/Documents etc. 
>> 
>> If I try a GRASS command such as "d.ask" in the RGUI after loading spgrass:
>> 
>> d.ask
>> Error: object 'd.ask' not found
>> 
>> 
>>
> 2. I can also get this to work in R directly: loc <- 
> initGRASS("C:/Program Files/Grass 6.4",home=tempdir()) gmeta6() **prints
> gisdbase, etc.** 
>> 
>> d.ask
>> Error: object 'd.ask' not found
>> 
>> 
>> Thank you for your help,
>> Laura 
>> 
> _______________________________________________
> grass-stats mailing list
> grass-stats at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-stats
>

-- 
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 grass-stats mailing list