[R] calling java from R and using java time series double precision array

Hurr hill0093 at umn.edu
Fri Mar 23 16:35:54 CET 2012


2012/3/23
Back again today at trying to learn R.
These are the results of a run I made. 
I understand very little of this. 
sapply() helps me get the array returned from a method.
Strings and doubles returned from a method don't seem to need sapply(). 
I want to learn how to fetch the constant array at the end of this run. 
I would like other education about this situation also.

> library(rJava)
> .jinit()
> .jaddClassPath("C:/ad/j")
> print(.jclassPath())
[1] "C:\\Users\\ENVY17\\Documents\\R\\win-library\\2.13\\rJava\\java"
[2] "C:\\ad\\j"                                                      
> qsLin <- .jnew("CalqsLin")
> calStg <- "201104242359599999"
> print(calStg)
[1] "201104242359599999"
> dblTim <-
> .jcall(qsLin,returnSig="D","linTimOfCalqsStgIsLev",calStg,as.integer(-4))
> print(dblTim,digits=20)
[1] 634709087999999.00000
> calStg <-
> .jcall(qsLin,returnSig="S","calqsStgOfLinTimIsLev",dblTim,as.integer(-4))
> print(calStg)
[1] "201104242359599999"
> dblTim <-
> .jcall(qsLin,returnSig="D","linTimOfCalqsStgIsLev",calStg,as.integer(-4))
> print(dblTim,digits=20)
[1] 634709087999999.00000
> arj34Ret <-
> sapply(.jcall(qsLin,returnSig="[[D","arReturnTEST"),.jevalArray)
>  #public final static double[][] arReturnTEST() { //this is the java
> method used 
>  #  double[][]retArr=new double[3][4]; 
>  #  for(int i=0;i<3;i++)for(int j=0;j<4;j++)retArr[i][j]=i*1000+j; 
>  #  return(retArr); 
>  #} 
> print(arj34Ret) # notice that the first java index is the column in R
> print 
     [,1] [,2] [,3]
[1,]    0 1000 2000
[2,]    1 1001 2001
[3,]    2 1002 2002
[4,]    3 1003 2003
> connArr <- .jevalArray(qsLin.conArr) # conArr is java two dim array of
> double precision constants 
Error in .jevalArray(qsLin.conArr) : object 'qsLin.conArr' not found
>  #public static double[][]conArr= { { 1001,1002,1003,1004 }, {
> 2001,2002,2003,2004 }, { 3001,3002,3003,3004 } }; 
> print(connArr) 
Error in print(connArr) : object 'connArr' not found
> 


--
View this message in context: http://r.789695.n4.nabble.com/calling-java-from-R-and-using-java-time-series-double-precision-array-tp4494581p4499206.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list