Archive for the ‘R project’ category

Setting up JRI with Eclipse on Mac OS X

November 26th, 2012

Dear all,

I had some difficulties in setting up the Java + R interface on my mac. At first, it didn’t find the jri library, then I had an error that the R_HOME variable was not set. Then, the program parameters were not set properly. This is how I got the whole thing working:

1. I copied the file libjri.jnilib to the folder /Library/Java/Extensions. The file can be found under /Library/Frameworks/R.framework/Versions/2.15/Resources/library/rJava/jri

2. I exported the R_HOME such: export R_HOME=”/Library/Frameworks/R.framework/Versions/2.15/Resources”

3. Under Eclipse I set  -> Run as -> Environment -> Variable R_HOME to /Library/Frameworks/R.framework/Versions/2.15/Resources

4. I set in Eclipse the -> Run as -> Arguments -> Program arguments to –no-save

Let me know if this helps you as well. Any feedback is greatly appreciated

Over and out! Stefan

Convert a decimal number to a date/time in R and Excel

October 22nd, 2010

My task was to convert a decimal number to a date/time format. It is easy to do in Excel but I found that Windows Excel and Mac Excel gave two different years. They differ by four years. The reason is that each one uses a different year for its origin. It is 1900-01-01 in Windows Excel and 1904-01-01 in Mac Excel. To get the right year in Mac Excel you can substract 1462 days from the numerical value…or you can uncheck the box under Formulas and Lists in the Excel settings panel.
Or you can do it in R by using the as.Date-function and the function times from the chron package.

as.Date(39011, origin=”1904-01-01″) # is “2010-10-22″ on Mac Excel
times(0.4872) # gives “11:41:34″

Cheers,
Stefan