[R] SJava convert problem

Spencer Graves spencer.graves at pdf.com
Fri Dec 3 07:43:11 CET 2004


      I have not previous knowledge of SJava, but I just went to 
www.r-project.org -> CRAN -> (selected a local mirror) -> "Software:  
Packages", and did not find SJava on the list.  Conclusion:  It's not a 
current R package.  I then went back to www.r-project -> search -> "R 
site search" -> SJava, and got 401 matches.  If you've already looked 
through them, then I apologize for wasting your time. 

      hope this helps. 
      spencer graves

Slim Shady wrote:

>Consider this Java class:
>class myClass {
>    final public static String[] testString () {
>        return new String[]{"my", "name", "is"} ;
>    }
>    
>    final public static int[] testInt () {
>        return new int[]{5, 10, 15};
>    }    
>    
>    final public static char[] testChar () {
>        return new char[]{'x', 'y', 'z'};
>    }
>
>}
>
>When invoked in R:
>  
>
>>s <- .Java(className, "testString")
>>class(s)
>>    
>>
>[1] "list"
>  
>
>>length(s)
>>    
>>
>[1] 3
>  
>
>>s
>>    
>>
>[[1]]
>[1] "my"
>
>[[2]]
>[1] "name"
>
>[[3]]
>[1] "is"
>
>
>  
>
>>c <- .Java(className, "testChar")
>>class(c)
>>    
>>
>[1] "character"
>  
>
>>length(c)
>>    
>>
>[1] 1
>  
>
>>c
>>    
>>
>[1] "X"
>
>  
>
>>i <- .Java(className, "testInt")
>>class(i)
>>    
>>
>[1] "integer"
>  
>
>>length(i)
>>    
>>
>[1] 3
>  
>
>>i
>>    
>>
>[1]  5 10 15
>
>Note that the conversion of testInt is just what I expected (and what
>I get in S-PLUS). The conversion of testChar is flat wrong because
>data is lost. The conversion of testString is problematic since I have
>to convert the list back using as.character (in S-PLUS this function
>returns character instaid of list and saves me the convertion from
>list to character)
>Is the convertion of char[] a bug? is there is a way to make the
>conversion of String[] returns a character class instaid of a list
>just like in the S-PLUS Java Connect?
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>

-- 
Spencer Graves, PhD, Senior Development Engineer
O:  (408)938-4420;  mobile:  (408)655-4567




More information about the R-help mailing list