<div dir="ltr"><div><div><div><div><div><div><div>Hi Andrew<br><br></div>The easiest way to get GRASS commands to run from within RStudio is:<br><br></div>1) Start GRASS<br></div>2) From the same command line start RStudio<br></div>3) in RStudio load the rgrass7 library: library(rgrass7)<br></div>4) Run your GRASS commands, e..g, execGRASS("g.region", flags="p")<br><br></div><div>Following these steps, there should be no need to run initGRASS(). Now, there are user cases in which you may want to run GRASS commands from R without first starting R from within a GRASS session, but from what you write the steps above are probably more convenient.<br><br>For more details on both approaches, see <a href="https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7">https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7</a></div></div><div><br></div>Paulo<br><div><div><div><div><div><div><div><div><div><div><br><br><br><div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Feb 7, 2016 at 6:56 PM, Andrew Plowright <span dir="ltr"><<a href="mailto:plowright.andrew@gmail.com" target="_blank">plowright.andrew@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Roger and Paulo,<div><br></div><div>Thanks for your replies. Just to be specific, I'm trying to run GRASS from within RStudio, not the other way around. I noticed that the version of rgrass7 I was using was built under R v.3.2.3, so I updated that. However, even when trying to run initGRASS() from RGui, I run into the same problem (I'm not quite sure how to run things from the command line).</div><div><br></div><div>When searching for solutions to this problem, I came across an old thread from this mailing list that said that initGRASS() was not necessary when GRASS was running. I launched GRASS, but still, when running loading the rgrass7 library from Rgui I get the message:</div><div><br></div><div><div>> library(rgrass7)</div><div>Loading required package: sp</div><div>Loading required package: XML</div><div>GRASS GIS interface loaded with GRASS version: (GRASS not running)</div></div><div><br></div><div>I guess R and GRASS are really just not communicating?</div><span class=""><font color="#888888"><div><br>Andrew</div></font></span></div><div class=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Feb 7, 2016 at 6:25 AM, Roger Bivand <span dir="ltr"><<a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sun, 7 Feb 2016, Andrew Plowright wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hello,<br>
<br>
I recently subscribed to this mailing list since I was hoping to get a bit<br>
of help setting up the rgrass7 package. I do all my GIS work in R, and am<br>
very excited by the prospect of using GRASS functions through the R<br>
environment. Unfortunately, I haven't gotten very far since I don't seem to<br>
be able to use the initGRASS() function correctly! When I run:<br>
<br>
library(rgrass7)<br>
initGRASS("C:\\Program Files\\GRASS GIS 7.0.3", home=tempdir())<br>
<br>
... R Studio simply runs forever. It does not give me an error message...<br>
it just keeps running until I force close the program. I am using R version<br>
3.2.2, and have installed GRASS version 7.0.3, which is installed in<br>
"C:\Program Files\GRASS GIS 7.0.3" folder. GRASS GIS seems to be running<br>
perfectly fine on its own.<br>
</blockquote>
<br>
<br>
Rstudio is very likely running the system*() commands and the commands setting environment variables in ways that interfere in your case. Start by using R from the command line, then RGui, then find out how to debug running functions in Rstudio and run initGRASS under the debugger to see at which step contact gets lost.<br>
<br>
I believe that there are reports of success using Rstudio within GRASS (in an existing GRASS location, starting Rstudio within GRASS).<br>
<br>
Does anyone have any experience? (I do not use Rstudio, so cannot tell - under Linux it wants R built in a specific way that I don't want to be forced to change to).<br>
<br>
Roger<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Any help would be greatly appreciated. Thank you!<br>
<br>
Andrew Plowright<br>
<br><span><font color="#888888">
</font></span></blockquote><span><font color="#888888">
<br>
-- <br>
Roger Bivand<br>
Department of Economics, Norwegian School of Economics,<br>
Helleveien 30, N-5045 Bergen, Norway.<br>
voice: <a href="tel:%2B47%2055%2095%2093%2055" value="+4755959355" target="_blank">+47 55 95 93 55</a>; fax <a href="tel:%2B47%2055%2095%2091%2000" value="+4755959100" target="_blank">+47 55 95 91 00</a><br>
e-mail: <a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a><br>
<a href="http://orcid.org/0000-0003-2392-6140" rel="noreferrer" target="_blank">http://orcid.org/0000-0003-2392-6140</a><br>
<a href="https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en" rel="noreferrer" target="_blank">https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en</a><br>
<a href="http://depsy.org/person/434412" rel="noreferrer" target="_blank">http://depsy.org/person/434412</a><br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div></div></div></div></div></div></div></div></div></div></div>