**From:** Rajarshi Guha (*rxg218@psu.edu*)

**Date:** Thu 27 May 2004 - 06:44:35 EST

**Next message:**Wolski: "Re: [R] time"**Previous message:**joseclaudio.faria: "[R] R: Help (two-way analysis of variance with contrasts)"

Message-id: <1085604274.9434.9.camel@blue.chem.psu.edu>

Hi,

I'm using SJava (0.65) to interface some Java code I have and am

having trouble understanding the use of arrays. I have a function:

tmv <- function(fname) {

a <- .JavaArrayConstructor("int", dim=c(3,0))

.JavaSetArrayElement(a, .JavaArrayConstructor("int", dim=3), 1)

.JavaSetArrayElement(a, .JavaArrayConstructor("int", dim=3), 2)

.JavaSetArrayElement(a, .JavaArrayConstructor("int", dim=3), 3)

for (i in 1:3) {

for (j in 1:3) {

.JavaSetArrayElement(a, as.integer(i*j), i,j)

}

}

print(.JavaGetArrayElement(a, 1,1))

}

I expect that I should see 1 print out but instead I get

[[1]]

[1] 1 2 3

[[2]]

[1] 1 2 3

The SJava manual seems to indicate that .JavaGetArrayElement(a, 1,1)

gives the first element of the first array.

Could anybody throw some light on this?

A related question is the an array of Strings.

Does .JavaArrayConstructor("String",3) give me an array of 3 Strings

(which are not yet defined) or a String of length 3? Or if I need to

allocate an array of Strings should I do:

r <- .JavaArrayConstructor( "String", c(3,0) )

and then for each element of r add a new array and then finally set the

individual elements to the actuial string values?

Is there any example code available that I could take a look at?

Thanks,

-------------------------------------------------------------------

Rajarshi Guha <rxg218@psu.edu> <http://jijo.cjb.net>

GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE

-------------------------------------------------------------------

Q: What's purple and commutes?

A: An abelian grape.

______________________________________________

R-help@stat.math.ethz.ch mailing list

https://www.stat.math.ethz.ch/mailman/listinfo/r-help

PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

**Next message:**Wolski: "Re: [R] time"**Previous message:**joseclaudio.faria: "[R] R: Help (two-way analysis of variance with contrasts)"

*
This archive was generated by hypermail 2.1.3
: Mon 31 May 2004 - 23:05:13 EST
*