10

I've managed to install StatET into eclipse, and I have a Java project called "Test" with some code in there. I'd like to be able to keep a .R file in that project folder and run it as a stand alone R script, seperate from the Java program. How can I do this? If I try to highlight some R code in a .R file and run it, it says "No session of R is active in the current workbench window."

Update: I added a run configuration and I now have the following error in a pop up box when I try to run the R script:

Launching the R Console was cancelled, because it seems starting the R engine failed. 
Please make sure that R package 'rj' (1.0.0 or compatible) is installed and that the R library paths are set correctly for the R environment configuration 'R'
CodeGuy
  • 28,427
  • 76
  • 200
  • 317
  • This is described in the StatET manual. In a nutshell, you fist have to configure a "Run Configuration" for R, and then run this configuration. – Andrie Feb 29 '12 at 16:36
  • could you direct me to a page number in the manual? i can't seem to find it. – CodeGuy Feb 29 '12 at 16:38
  • 1
    If I type "run configuration" in the search bar for my pdf reader I get directed to pg 25. – IRTFM Feb 29 '12 at 18:35

3 Answers3

13

You need to first start an R console from within Eclipse. Select Run -> Run Configurations... from the menu bar. If you have not already created an R configuration, you can create a new one by right-clicking on R Console. For more information, Longhow Lam put together a nice guide (PDF).

EDIT: Regarding your new error message, make sure rj is installed in R by running one of these commands in the command-line version of R. For the current StatET 2.0:

install.packages(c("rj", "rj.gd"), repos="http://download.walware.de/rj-1.0")

For the development StatET 3.0:

install.packages(c("rj", "rj.gd"), repos="http://download.walware.de/rj-1.1")

For the old StatET 0.10:

install.packages("rj", repos="http://download.walware.de/rj-0.5")

EDIT2

Its now

install.packages(c("rj", "rj.gd"), repos="http://download.walware.de/rj-2.1")

Also see http://www.walware.de/it/downloads/rj.02.01.html

Stefan
  • 10,010
  • 7
  • 61
  • 117
jthetzel
  • 3,603
  • 3
  • 25
  • 38
  • okay, I made a configuration. how do I run R using that configuration. I still get the same error. – CodeGuy Feb 29 '12 at 16:41
  • in the Config tab of my new R configuration, it says " The R Environment preferences of the Workspace are invalid" – CodeGuy Feb 29 '12 at 16:44
  • @CodeGuy - Select `Run -> Run Configurations`. It should appear in the left panel under `R Console`. Select it and hit `Run`. – jthetzel Feb 29 '12 at 16:45
  • the run button is disabled...perhaps because of the error I mentioned? – CodeGuy Feb 29 '12 at 16:47
  • @CodeGuy: When you configure the R environment, which Architecture is listed? It should be `x86-64` for 64 bit R. I seem to remember StatET defaulting to an incorrect value in the past. – jthetzel Feb 29 '12 at 16:49
  • @CodeGuy: When the run button is disabled, an error message is usually displayed at the top of the window to hint at the problem. – jthetzel Feb 29 '12 at 16:58
  • Yes, it is set to be x86-64. I have updated the question with a new error. Please check it out. Thanks! – CodeGuy Feb 29 '12 at 18:04
  • If your rj library is installed in user directory then add this directory in Window --> Preference --> StatET --> R Environments --> --> Site Libraries – Keyur May 16 '16 at 07:24
  • I used the launch type RTerm because RJ 2.1 gives me an error "Fehler: Hauptklasse de.walware.rj.server.RMIServerControl konnte nicht gefunden oder geladen werden Ursache: java.lang.ClassNotFoundException: de.walware.rj.server.RMIServerControl" – Stefan Dec 22 '17 at 14:15
4

Just had same error message and finally found that it's due to the lack of privileges to write to the library directory under R. Therefore although Eclipse shows that RJ is installed, it's actually not.

re-installed RJ to a user directory and added the directory to the R console config, it worked.

msj121
  • 2,812
  • 3
  • 28
  • 55
jack
  • 41
  • 1
0

For me I have to change in run/run configuration/launch type to put the value "Rterm" because it was to RJ by default and do the same config that jthetzel said in R-config -> configure -> add -> + -> try to find automaticly -> apply.

bormat
  • 1,309
  • 12
  • 16