[R-sig-Geo] GRASS with R interface issues - running R within GRASS 6.4.2
Roger Bivand
Roger.Bivand at nhh.no
Mon Apr 23 11:21:16 CEST 2012
On Mon, 23 Apr 2012, Laura S wrote:
> Dear all:
>
>
> Should I reinstall GRASS and set up some sort of path, so that R is
> recognized? Would anyone be able to send me key words to find more
> basic, newbie, information on "PATH" and "R_LIBS"? I would like to find
> the paths, and set the proper variables, but I am unsure where to start.
> I have fiddled in GRASS now without R, but I would like to use R within
> GRASS.?
>
Please do try to search more effectively. The standard way of running R
inside GRASS on Windows is to start GRASS first in the location you are
using, then enter the complete path to R at the MSYS prompt. The complete
path is the same as the string shown as Target: under Properties if you
right-click on the R icon on your Windows desktop. For example:
"C:/Program Files/R/R-2.15.0/bin/i386/Rgui.exe"
or the equivalent for your installation. You may also need to set the
environment variable R_LIBS if R cannot "find" the correct library
containing the packages you need.
If you are not using a GRASS location, you may use the initGRASS()
function in spgrass6 to start a temporary GRASS session, often in a
throw-away location, because you only need to move objects from R to
GRASS, use GRASS on them, and move the output objects back to R. Then you
need the complete path to the GRASS install directory, for example:
"C:/Program Files/GRASS 6.4.2"
or the equivalent for your installation.
It is also possible to use initGRASS() with existing locations in a
scripting context, but this is not your case.
The grass-stats mailing list is often used for questions like this.
Hope this clarifies,
Roger
> Which location should I do all this
> in? There are more than option for GRASS, e.g., command line, GUI (with
> MSYS, without, etc.), MSYS UNIX console; I am not sure which one to use
> for loading R within GRASS.
>
>
> Any suggestions are much appreciated.
>
> Thank you,
> Laura
>
>
>> Dear all:
>>
>> I am trying to get
> R to run with grass, but I am running into trouble.
>>
>>
>> This is what I have done so far:
>>
>> Installed GRASS 6.4.2 for Windows XP
>> Installed spgrass6 with dependencies.
>>
>> When I do:
>> library(spgrass6)
>> gmeta6()
>>
>> I get the following:
>> Error in system(cmd0,intern=TRUE); "g.region.exe' not found
>> Error in parseGRASS(cmd) : g.region not found.
>>
>>
> Any suggestions are much appreciated. I am new to using GRASS with R,
> but I am looking forward to using them together to analyze data.
>>
>>
> I am unsure which terminal to run R in GRASS because I keep getting
> errors in the command console in GRASS: I type into either "Command
> console in GRASS GIS Layer Manager" OR "GRASS Command Line":
>>
>> R
>> ...Then I get
>>
>> 'R' is not recognized as an internal or external command, operable program or batch file.
>
> This
> suggests that you need to give the complete path to R from within your
> GRASS session. It may be "C:/Program Files/R/R-2.14.1/bin/Rgui.exe" or
> something like that, depending on where you installed it. You may also
> need to add R_LIBS="<whatever>" to this, to show where any local
> libraries may be.
>
> Alternatively, you may try to add R's binary
> location to your PATH environment variable, and declare R_LIBS globally;
> these used to be under advanced system properties.
>
> Finally, as
> Rainer suggests, you may start GRASS from within R, using the same logic
> in reverse, giving the full path to the GRASS install location to the
> initGRASS() function. The key in both cases is to find out where in your
> file system the software components live, and note changes when you
> upgrade.
>
> Hope this helps,
>
> Roger
> [[alternative HTML version deleted]]
>
>
--
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