Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
339 views
in Technique[技术] by (71.8m points)

r - How does one install 'rj' in StatET plugin for Eclipse?

I have started to try to use StatET and Texlipse with a view to producing SWEAVE reports. When starting the R console in the StatET plug-in for Eclipse (OS X 10.6.4), I get the message:

[INFO] The R package 'rj' is not available, R-StatET tools cannot be initialized.

Information on http://www.walware.de/goto/statet states:

"The package only works in the default R Console (RJ) in StatET. Therefore you have to install and update it using the command line":

R CMD INSTALL --no-test-load rj_*.tar.gz

What does this mean exactly?

In Eclipse under "Install new Software" and the site

WalWare - http://download.walware.de/eclipse-3.6

it states that

  RJ Core Library 0.5.0.b201008271600sw

is already installed.

Any helpful guidance gratefully received.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

[rant] I also lack the reputation to put my response where it belongs. And there's no button there indicating this. Just a big screen full of nowhere desired to click upon. Negative discoverability sucks. It sucks in Eclipse and it sucks here, too. [/rant]

I'm finding rj frustrating under Ubuntu. On my system, with each major Ubuntu upgrade with a new version of R, I have to go through this procedure over again.

One time I tried to use a tilde (~) character in a path name within some Eclipse configuration field. This failed silently.

My current configuration is as follows. In my ~/.Renviron file:

R_LIBS_USER=~/etc/R/amd64/2.11

Once rJava works, there is an rJava directory here. Just so I don't drive myself insane, in ~/etc/R/README I put a note that my current R configuration is controlled by ~/.Renviron

Somehow at one point I ended up with permission problems where

R CMD javareconf 

was failing. Once in frustration I foolishly ran this under sudo to work around this problem, and ended up with permission problems on the generated files. Stupid! The correct fix was to make all the files in /etc/R world readable. Maybe javareconf is only important if you mess with your default Java. Previously, I was running the Sun's JRE. Since 10.10 I'm running icedtea6 and it seems to be working OK. One time it was just the thing to make my configuration work again.

Once I have the right Java binding, from command line R:

install.packages("rJava")

I've had file permission problems running this in the past. I think it was fixed by making all files in /etc/R world readable.

The following is a useful diagnostic to see if this worked, from within any R console:

> system.file("jri",package="rJava")
[1] "/home/allan/etc/R/amd64/2.11/rJava/jri"

If it doesn't look right under Eclipse, there is also some startup debugging available, though it took forever before I noticed this in the docs at StatET.

I created an R Console run configuration for R 2.11 debug In the JRE tab add -Dde.walware.rj.verbose=true. In the Common tab, click Allocate additional Error Log Consoles.

The main configuration options are as follows. Main tab, Launch Type: RJ. R_Config tab, you need to select a Configured R Installation, or create/edit one if you don't have one that works. Mine is Name=R, Location=/usr/lib64/R In the Environment tab I have R_LIBS_USER=/home/USER/etc/R/amd64/2.11 according to how I set things up above. Do not use the tilde (~) character here!

If you end up mucking about with this problem as much as I did, you end up killing a lot of dead consoles. In the Main tab I added the program option --no-save. I don't think this does anything, since I can't end my console by pressing CTRL-D. In the R_Console tab, I added the following R snippet:

q <- function(save = "no", status = 0, runLast = TRUE){
.Internal(quit(save, status, runLast))
#<environment: namespace:base>
}

This gets rid of the annoying "save workspace" prompt when killing an R console with the red square (is that symbolic?) My current workspace also includes a C project, so my R console constantly comes up underneath a blank C-Build console. Annoying as all hell! Haven't solved that yet, but I did discover that from within a StatET code windows the keybinding CTRL-R C pulls the R console to the top.

With my R 2.11 debug configuration I get an extra console titled /usr/lib/jvm/java-6-openjdk/bin/java. You'll have to spelunk the console drop-down to find it. The following is a pertinent snippet of a successful initialization:

CONFIG: JR library path: 
    /home/allan/etc/R/amd64/2.11
    /usr/local/lib64/R/site-library
    /usr/lib64/R/library
10-Dec-2010 7:56:47 AM org.rosuda.rj.JRClassLoader addClassPath
FINE: Added '/home/allan/etc/R/amd64/2.11/rJava/java' to classpath of URL loader  

A lot more spoo, then finally:

10-Dec-2010 7:56:48 AM de.walware.rj.server.jriImpl.RosudaJRIServer start
INFO: R engine started successfully. New Client-State: 'Connected'.

Looks good, right? But lo and behold in the R console:

[INFO] The R package 'rj' is not available, R-StatET tools cannot be initialized.

Ignore the lying bastard! Turns out my rj is working just fine. No idea why this failure message persists.

Every time around the block with this problem some new amazing piece of gravel ends up in my sneaker.

I don't know whether I've covered everything, but I've written enough for now. Maybe if there are comments I'll come back and fill in the blanks.

Note: found an Eclipse plugin for console switching by keyboard here: Eclipse: Keyboard shortcut for switching between consoles?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...