[GRASS-stats] GRASS within R interface issues

Laura S les_ecol at yahoo.com
Fri May 4 13:03:29 EDT 2012


Dear Roger:

What I have been seeking to do from the very beginning is to run R within GRASS directly on XP. In other words, type "R" in the GRASS console and have R run. This does not workfor me yet. I have looked in books/websites. From what I have read, they indicate that you run R within GRASS, but not the actual set up to make R recognizable to GRASS when it spits out " 'R' is not recognized as an internal or external command, operable program or batch file"; the output that has started this whole process of me trying to figure out the disconnect. Here is an example of what I want to do, and how when I try to do the same operation it fails:
######### Startup 
	* Start GRASS. At the GRASS command line start R. 
In this example we will use the sample Spearfish dataset. 
Reset the region settings to the defaults 
GRASS> g.region -d 
Launch R from the GRASS prompt 
GRASS> R 
Load the spgrass6 library: 
> library(spgrass6) 
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G: 
> G <- gmeta6() 
########### This is what I get from the GRASS command line, which mirrors the MSYS, etc. problem I am having:
GRASS 6.4.2RC2> g.region -d 
Launch R from the GRASS prompt 
GRASS 6.4.2RC2> R
'R' is not recognized as an internal or external command, operable program or batch file 
########## Others are having the same problem, and I have had people email me privately to let them know what I uncover. 


Cheers,
Laura



________________________________
 From: Roger Bivand <Roger.Bivand at nhh.no>
To: Laura S <les_ecol at yahoo.com> 
Cc: "grass-stats at lists.osgeo.org" <grass-stats at lists.osgeo.org> 
Sent: Friday, May 4, 2012 12:12:29 AM
Subject: Re: [GRASS-stats] GRASS within R interface issues 
 
On Fri, 4 May 2012, Laura S wrote:

> Dear Roger:
> 
> Thank you. I am still puzzling a bit. Now the following happens: (i) R pops up, (ii) GRASS is not frozen, (ii) but there is no recognition of R in GRASS GUI with MSYS. How do I get R to be recognized directly within GRASS? I keep getting "sh: R: command not found" in the GRASS GUI with MSYS. 
> Here are my newest steps thus far:
> 
> 1. In GRASS GUI with MSYS:
> GRASS 6.4 > "C:/Programs.../Rgui.exe" &
> [1] 3532
> 
> 2. Pops up R window without freezing console, but still does not recognize R, as shown in # 3.
> 
> 3. GRASS 6.4 > R
> sh: R : command not found

Well, you have a running R session, do you want a second one? If you prefer not to use the R GUI, you may use R.exe in step 2 but without the &, as then the R CLI will run in the MSYS console. I do not understand why you do step 3 - you asked before about issuing GRASS commands at the MSYS prompt? Can you get local help from someone who can look over your shoulder?

Roger


> 
> Thank you,
> 
> Laura
> 
> 
> 
> 
> ________________________________
> From: Roger Bivand <Roger.Bivand at nhh.no>
> To: Laura S <les_ecol at yahoo.com> Cc: "grass-stats at lists.osgeo.org" <grass-stats at lists.osgeo.org> Sent: Wednesday, May 2, 2012 11:44:57 AM
> Subject: Re: [GRASS-stats] GRASS within R interface issues 
> 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
> 

-- 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-stats/attachments/20120504/92c0bec9/attachment.html


More information about the grass-stats mailing list