I just now registered in R forum. I use Windows because of past history of using windows. I have been writing and using programs in java for about a decade. I work with unequal-interval-time-series data files, 1st 5 lines like: Title Line CnYrMoDaHrMnScDCMQ,ColSerTit1,ColSerTit2,ColSerTit3,ColSerTit4, 201104212359599999,Ser1Datum1,Ser2Datum1,Ser3Datum1,Ser4Datum1, 201104220059428739,Ser1Datum2,Ser2Datum2,Ser3Datum2,Ser4Datum2, 201104220103369291,Ser1Datum3,Ser2Datum3,Ser3Datum3,Ser4Datum3, where e.g.Ser4Datum3 is a number, and calendartime unit can be anywhere from Da down to Q (Quadiseconds), a lot stops at Mn. Time is same unit throughout any one file. Getting to the point: I have all of the calendar-linear conversion and file reading subroutines as Java methods and would like to use them in R. I am not very knowledgeable yet about R. I need instructions about how to set up and use java in R on Windows. Can anyone help me with setup instructions then starting with a simple Java function (method) call. One problem with Java is that a function returns only one item. -- View this message in context: http://r.789695.n4.nabble.com/Using-Java-methods-in-R-tp3469299p3469299.html Sent from the R help mailing list archive at Nabble.com.
No answer to my post, so let's try a simpler question. Am I doing this correctly? I have the RGui with R Console on the screen. On rhe top pullDowns, Packages > Install Packages > USA(IA)> rJava> library(rJava) > .jinit() > qsLin <- .jnew("C:/ad/j/CalqsLin")Error in .jnew("C:/ad/j/CalqsLin") : java.lang.NoClassDefFoundError: C:/ad/j/CalqsLin So I got this error which means I don't understand very much. I go to C:/ad/j and get C:\ad\j>dir CalqsLin.class Volume in drive C has no label. Volume Serial Number is 9A35-67A2 Directory of C:\ad\j 04/23/2011 07:11 AM 14,651 CalqsLin.class 1 File(s) 14,651 bytes 0 Dir(s) 104,257,716,224 bytes free Just to show my intentions, I had next wanted to call this java function method: linTimOfCalqsStgIsLev("201104052359599999",-4) using:> dblTim <- > .jcall(qsLin,"D","linTimOfCalqsStgIsLev","201104052359599999","-4")but that will probably also be wrong? Obviously I don't understand. -- View this message in context: http://r.789695.n4.nabble.com/Using-Java-methods-in-R-tp3469299p3469848.html Sent from the R help mailing list archive at Nabble.com.
Hi Hill, I just finished interfacing the C++ with R, i.e. c++ functions from R and vice versa. Next thing in pipe line is Java and python. I just wanted to share some of the things which i think might be useful for you. Reason being whether its a C++, java or any other compiled language the interface has to be generic in R. That means mode of interfacing might be different(using different packages Rcpp for c++, rJava for Java) but the underlying mechanism remains the same. For C++ you will be creating a dll ( windows) and .so( *nix) and for jave you will be using class. Now for using c++/java functions with in R or vice versa, you first should check whether the functions are properly loaded in the R symbol table or not? If you are unable to call the java functions in R, then probably you are unable to load the class into the R environment. A few steps which i have followed in C++ ( i think must be more or less same conceptually) could be useful for you: 1) I have a c++ file, i compile it using the command R CMD SHLIB filename.cpp. On successful completion it creates the library. if you are getting compilation error then you need to check whether the header files are in proper path or not. 2) Then for using this function is first use to load the library using the function dyn.load("library path") 3) If the loading is successful i check whether the required function is properly loaded into the R symbol table or not by using the function is.loaded("function name") 4) if it returns true, then i call the function by using .C or .Call function provided by R. For more information you can see http://groups.google.com/group/brumail/browse_thread/thread/a278dcbb6a8a439a . Hope it helps you in someway. Regards, Som Shekhar