To talk to R through Java you have to specify three more environmental variables. First of all you need to publish you R installation path, my R is found in
If you didn’t or the path is wrong you’ll fall into trouble:
$CLASSPATH needs to get an update. Precisely you have to add the archives
REngine.jar . In my case all of them can be found in
/usr/lib/R/site-library/rJava/jri/ , so the
$CLASSPATH should be set like that:
$CLASSPATH isn’t defined correctly you won’t be able to compile your Java code.
Last but not least you have to add the native JRI-library to your
$LD_LIBRARY_PATH , by default this lib is located in the same directory like the jar’s:
$LD_LIBRARY_PATH isn’t proper you’ll experience errors like this:
To not always do the same you might write these export stuff to your
Of course in Eclipse you’ll also have to define these three things.
Where are the jar’s located? Add them to your libraries in Project > Properties > Java Build Path > Libraries.
Instead of the
$LD_LIBRARY_PATH you can set the
java.library.path in Run > Run Configurations > Arguments. Add
-Djava.library.path=.:/usr/lib/R/site-library/rJava/jri/ to the VM arguments (modify the path to match your criteria).
R_HOME can be published in Run > Run Configurations > Environment. Create a new variable with the name
R_HOME and the value
/usr/lib64/R (or an equivalent path).
That’s it, see the section above to identify what went wrong if something fails.
Two of these three parts are also straight forward in Netbeans.
First publish the location of the jar’s. Right-click on your project and choose Properties > Libraries. In the Compile-tab click Add JAR/Folder and search for the jar files.
Next task is to adjust the library-path. Right-click on your project and choose Properties > Run. Add
-Djava.library.path=.:/usr/lib/R/site-library/rJava/jri/ to the VM Options (modify the path to match your criteria).
The third step is a little tricky. As far as I know there is no way to change the environment from within Netbeans, so you can’t create the variable
R_HOME after Netbeans is started. In my opinion you have two options:
- Export the variable before starting Netbeans:
you might want to write a wrapper script that does this step for you, or include the export in any of the resource files that are called before Netbeans starts (e.g. your
- Change the environment from within your project. At stackoverflow you can find a workaround, but I think this is a very lousy solution..
If you defined your environment properly, you should be able to utilize the REngine. I have a small script for you to test whether all things are fine:
You should be able to compile and run it, afterwards you’ll see a random number from an uniform distribution. Congratulations, well done :-P
I have bad news for those of you trying to produce lucid code!
In his blog Radford M. Neal, Professor at the University of Toronto, published an article with the headline Two Surprising Things about R. He worked out, that parentheses in mathematical expression slow down the run-time dramatically! In contrast it seems to be less time consuming to use curly brackets. I verified these circumstances to be true:
As you can see adding extra parentheses is not really intelligent concerning run-time, and not in a negligible way. This fact shocked me, because I always tried to group expressions to increase the readability of my code! Using curly brackets speeds up the execution in comparison to parentheses. Both observations are also surprising to me! So the conclusion is: Try to avoid redundant parentheses and/or brackets!
To learn more about the why you are referred to his article. He also found a interesting observation about squares. In a further article he presents some patches to speed up R.
Ok, R is very well-considered in certain respects, but there are also some things annoying me… This time it’s scoping…
Let’s have a look to the following code:
First it looks damn unspectacular. But wait, whats that:
Taking a closer look to the function shows that the returned value is randomly chosen from local (
runif(1) > .5 ) or global scope (
runif(1) <= .5 ). So you can’t expect a result from this function. Nasty, especially while debugging external code, isn’t it? :-)
So again my advise: Think about such specific features! This won’t happen in any sensible language…
Sitting on an almost well configured host, I experienced some authentication issues the last few days…
Mmh, that is crap. My workaround to temporarily avoid this problem: Connecting to another host via SSH, running xtrlock within a GNU screen session ;-)
But that’s no solution for a longer time… So I started debugging. First of all I grabbed the sources from the apt repository and searched for this error message. Turned out to be this piece of code (beginning with line 94 of
Ok, seems that the provided password(-hash) is shorter than 13 characters… Going on debugging, the content of
pw comes from
getpwuid(getuid()) and seems to be ok (matches my users profile like it can be found in
/etc/passwd ). At this time (line 1)
pw->pw_passwd contains only an single
x , more information can’t be retrieved from the
Next the code checks whether
SHADOW_PWD is defined, means whether we use an additional
shadow -file. Since thats the case this code is executed and the variable
sp gets the broken-out fields of the record in the shadow password database that matches the username
pw->pw_name (validated, my user). Checking this
sp variable I recognized that it is
null ! So
pw->pw_passwd won’t be updated and still contains the single
x from the passwd entry…
First I thought about a bug in the
getspnam () function, such things might happen due to the Debian unstable release I’m using, but after some further thoughts I checked the shadow file itself:
In comparison with other systems with working xtrlock instances I figured out, that this file shouldn’t only be owned by root. Instead the group has to be shadow! So here is the solution to this issue:
And everything is working fine again. Have no idea what or who changed the permissions for the shadow-file…
By the way, afterwards I tried to use Xscreensaver instead of xtrlock, but I wasn’t able to unlock the screen when the shadow rights are wrong. The
/var/log/auth.log held messages like that:
But this is just for google-searchers ;-)
He send some saliva to 23andme, they analyzed his DNA and provided his genetic code to him (let’s neglect the discussion whether data from 23andme-chips represent a fully sequenced genome..). This process is very smart and not expensive, so this part of his announcement is not spectacular. Lot’s of people are doing so.
The interesting part of this article: He published the results (roughly 1 million SNP markers) from 23andme as open source project to github, licensed under CC0! So he has released all his rights on this data.
In general a very impressing step, he might be the first person who published its DNA under such a license. His intentions are more than exemplary, providing access to genetic data to everyone that wants to work with it, i.e. researchers.
So far, so good, but there are some disadvantages, he still dealt with some of it. For example, what if anybody uses this information against him? I.e. healthcare provider, they might deny him to avoid high costs because they detected some pre-existing conditions in his DNA. It may also affect employment and can lead to discrimination. His reaction:
I’ve thought long and hard about each of those questions and the many more that you ask yourself before publishing this sort of personal data. There are large privacy implications in doing this. However, speaking solely for myself, I think the benefits outweigh the drawbacks.
Very nice, but there are also some ugly implications he apparently didn’t thought about! All these disadvantages don’t only affect himself, they may also affect relatives (children, parents, siblings..). Did they all agree with this publication?
I can’t see the advantages to an anonymously publication. Attach some demographic information like age, gender, educational background and everyone is satisfied. Then you don’t have to bear any consequences with bugs in your DNA.
With all due respect for his engagement, I think this step is not really sophisticated.