Thanks for your prompt reply Martin. That should work, but still involves changing the java code.
I was just hoping there might be an obvious solution I was missing. Sorry for the mailing list wrongness. I didn't realise there was an rJava mailing list. Thanks, ben On 19/02/2008, Martin Morgan <[EMAIL PROTECTED]> wrote: > > Ben > > R represents matrices as a vectors (the result of as.vector(t) on > your data below) with a 'dim' attribute, and I bet that this is how > they're passed to Java. Write a method with sig > > public void data.structure.DistanceMatrix.setDistances(double[] data, > int[] dim) > > invoked along the lines of > > .jcall(distanceMatrix, "V", "setDistances", as.vector(t), dim(t)) > > (sorry, I'm a bit rusty on this so details might be incorrect) > > This probably belongs on R-devel, if not on the rJava mailing list. > > Martin > > "Ben Woodcroft" <[EMAIL PROTECTED]> writes: > > > Hi list, > > > > I'm wanting to use a matrix as input to some java code, but I seem to be > > unable to do this (See code below). When searching online for a solution > I > > found that rJava 0.5-2 (the version under development not yet in CRAN) > is > > adding "direct support for raw vectors as method parameters". Is this > > related? > > > > I also tried to use .jarray / .jcast in various combinations to no > avail. > > > > The only way I can think of to solve this is to modify the java code to > > allow me to upload a row of the matrix one at a time. > > > > Any other ideas? > > > >> require(rJava); > > Loading required package: rJava > >> t = rbind(c(1,2,3),c(2,3,4),c(1,2,10)); > >> .jinit() > >> distanceMatrix = .jnew("data/structure/DistanceMatrix"); > > > >> .jmethods(distanceMatrix); > > ... other methods omitted for brevity ... > > [4] "public void data.structure.DistanceMatrix.setDistances > (double[][])" > > > >> .jcall(distanceMatrix, "V", "setDistances", as.matrix(t)); > > Error in .jcall(distanceMatrix, "V", "setDistances", as.matrix(t)) : > > method setDistances with signature ([D)V not found > > Calls: .jcall -> .External > > Execution halted > > > > > > > > Thanks in advance, > > ben > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > -- > Martin Morgan > Computational Biology / Fred Hutchinson Cancer Research Center > 1100 Fairview Ave. N. > PO Box 19024 Seattle, WA 98109 > > Location: Arnold Building M2 B169 > Phone: (206) 667-2793 > -- FYI: My email addresses at unimelb, uq and gmail all redirect to the same place. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.