Hi,
You really should use the REngine API, which lets you control jri and
Rserve using the same api. See the org.rosuda.REngine package in
http://www.rforge.net/org/docs/
Either wayn, I have no problem evaluating the problematic string with
both apis.
Romain
On 12/02/2009 03:26 PM, Jean Couteau wrote:
FWIW the restriction is only on the console input - if you send it
directly, there is no limit (I have never heard of nuiton-j2r but if
you use rJava to interface from Java to R there is no limit - the
string you parse+evaluate can be of any length).
Hi Simon,
nuiton-j2r is in fact an abstraction layer to rjava or rserve so that it
can switch between one or other implementation using simple
configuration (http://maven-site.nuiton.org/nuiton-j2r/ sorry but this
is in french). And in fact I encounter the problem using it.
What is done is basically creating the R instruction from java and
sending it to R using the eval method from the Rengine object (as we use
jri in this specific application). The R instruction should create an
object a of class morris, and I try then to get back the a$X object (the
X item of the morris object) but I get back a null object without any
reason, that is why I tried copying the instruction directly in R and
thus getting this problem.
So that is strange if you say that there is no limit using rjava/jri.
Cheers,
Jean
Cheers,
Simon
Duncan Murdoch wrote:
On 01/12/2009 12:50 AM, Jean Couteau wrote:
Thanks for your time Duncan,
I join here the instruction that is not correct, hoping that might
help you. The file is encoded in utf-8 so you should not have any
problem reading it.
I doubt to that it is an R bug too, but with all my tests i am less
and less sure of that.
I have no problem sourcing that file, but I do get an error if I try
to cut and paste it, because it's a single line of 4890 characters,
and that's too long. So this is an R limitation, but it's one with
an easy workaround: just add some line breaks into your source.
Duncan Murdoch
Best regards,
Jean Couteau
Your message has encoding problems, so it's not readable. Could
you put the code online somewhere where we could download it in
its original form? I doubt if this is an R bug, but I can't point
out the problem in your code (or confirm that it really is an R
bug) without an undamaged copy of the code.
Duncan Murdoch
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/Gq7i : ohloh
|- http://tr.im/FtUu : new package : highlight
`- http://tr.im/EAD5 : LondonR slides
import org.rosuda.REngine.* ;
import org.rosuda.REngine.JRI.* ;
public class MorrisREngine {
public static void main(String[] args) {
String cmd = "a<-morris(model=NULL,factors=c(\"PecheAmateurs
décembre.proportionMetier\",\"PechePetitMetierMer
mai.proportionMetier\",\"PecheAmateurs mai.proportionMetier\",\"PecheChalutiere
janvier.minInactivityDays\",\"PechePetitMetierEtang
octobre.minInactivityDays\",\"PechePetitMetierEtang
décembre.minInactivityDays\",\"FiletMer.standardisationFactor\",\"PecheAmateurs
juin.minInactivityDays\",\"PechePetitMetierEtang
novembre.minInactivityDays\",\"PechePetitMetierMer
septembre.minInactivityDays\",\"PechePetitMetierMer
avril.minInactivityDays\",\"PecheAmateurs
août.proportionMetier\",\"PecheChalutiere
novembre.minInactivityDays\",\"PechePetitMetierMer
février.proportionMetier\",\"PecheChalutiere
juillet.minInactivityDays\",\"PechePetitMetierMer
octobre.proportionMetier\",\"CSar Groupe
5.reproductionRate\",\"PechePetitMetierMer
août.proportionMetier\",\"PechePetitMetierMer
janvier.minInactivityDays\",\"PechePetitMetierEtang
mai.minInactivityDays\",\"PecheAmateurs
octobre.minInactivityDays\",\"PecheAmateurs
septembre.minInactivityDays\",\"PecheChalutiere
juin.minInactivityDays\",\"PecheChalutiere
avril.minInactivityDays\",\"PecheAmateurs
juillet.proportionMetier\",\"PecheChalutiere
mai.minInactivityDays\",\"PechePetitMetierEtang
septembre.minInactivityDays\",\"PechePetitMetierMer
janvier.proportionMetier\",\"PecheAmateurs
septembre.proportionMetier\",\"PechePetitMetierEtang
février.minInactivityDays\",\"PechePetitMetierEtang
mars.minInactivityDays\",\"PechePetitMetierEtang
juillet.minInactivityDays\",\"PechePetitMetierMer
septembre.proportionMetier\",\"CSar.capturability\",\"PechePetitMetierMer
juin.proportionMetier\",\"PecheChalutiere
mars.minInactivityDays\",\"PecheChalutiere
septembre.minInactivityDays\",\"PecheAmateurs
janvier.minInactivityDays\",\"PechePetitMetierMer
août.minInactivityDays\",\"PechePetitMetierMer
juillet.proportionMetier\",\"PecheChalutiere
décembre.minInactivityDays\",\"PecheAmateurs
avril.minInactivityDays\",\"PecheAmateurs
mars.proportionMetier\",\"PechePetitMetierMer
novembre.minInactivityDays\",\"PechePetitMetierEtang
août.minInactivityDays\",\"CSar.recruitmentDistribution\",\"PecheChalutiere
février.minInactivityDays\",\"CSar.naturalDeathRate\",\"PecheAmateurs
octobre.proportionMetier\",\"PechePetitMetierMer
mai.minInactivityDays\",\"PechePetitMetierMer
mars.proportionMetier\",\"PecheAmateurs
août.minInactivityDays\",\"FiletEtang.standardisationFactor\",\"PecheChalutiere
août.minInactivityDays\",\"PecheAmateurs
janvier.proportionMetier\",\"PecheAmateurs
décembre.minInactivityDays\",\"PechePetitMetierEtang
avril.minInactivityDays\",\"PecheAmateurs
mars.minInactivityDays\",\"PechePetitMetierMer
décembre.minInactivityDays\",\"PecheAmateurs
mai.minInactivityDays\",\"PechePetitMetierEtang
juin.minInactivityDays\",\"Harpon.standardisationFactor\",\"PecheAmateurs
novembre.minInactivityDays\",\"PecheAmateurs
novembre.proportionMetier\",\"PechePetitMetierMer
mars.minInactivityDays\",\"Ligneemb.standardisationFactor\",\"PecheAmateurs
juin.proportionMetier\",\"PecheAmateurs
avril.proportionMetier\",\"PechePetitMetierMer
juillet.minInactivityDays\",\"PechePetitMetierMer
avril.proportionMetier\",\"PechePetitMetierMer
octobre.minInactivityDays\",\"PechePetitMetierMer
février.minInactivityDays\",\"PecheAmateurs
juillet.minInactivityDays\",\"PechePetitMetierMer
décembre.proportionMetier\",\"PecheAmateurs
février.proportionMetier\",\"PecheChalutiere
octobre.minInactivityDays\",\"CSar Groupe 4.reproductionRate\",\"CSar Groupe
7.reproductionRate\",\"Lignecote.standardisationFactor\",\"CSar.meanWeight\",\"CSar
Groupe 6.reproductionRate\",\"PechePetitMetierMer
juin.minInactivityDays\",\"PechePetitMetierMer
novembre.proportionMetier\",\"PechePetitMetierEtang
janvier.minInactivityDays\",\"PecheAmateurs
février.minInactivityDays\",\"CSar.growth\"),r=10,design=list(type=\"oat\",levels=c(5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5),grid.jump=c(2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2)),binf=c(0.0,0.0,0.0,11.0,10.0,12.0,0.06,10.0,11.0,0.0,0.0,0.0,10.0,0.0,11.0,0.0,1120.0,0.0,10.0,22.0,12.0,10.0,10.0,11.0,0.0,11.0,15.0,0.0,0.0,23.0,16.0,22.0,0.0,0.0,0.0,11.0,10.0,18.0,0.0,0.0,11.0,11.0,0.0,3.0,22.0,0.0,8.0,0.0,0.0,0.0,0.0,8.0,0.1456,11.0,0.0,18.0,17.0,11.0,7.0,11.0,20.0,0.0464,16.0,0.0,1.0,0.1515,0.0,0.0,0.0,0.0,1.0,11.0,9.0,0.0,0.0,11.0,1120.0,1120.0,0.0749,0.0,1120.0,0.0,0.0,13.0,16.0,0.0),bsup=c(1.0,1.0,1.0,15.0,14.0,16.0,0.09,14.0,15.0,2.0,2.0,1.0,14.0,1.0,15.0,1.0,1680.0,1.0,14.0,26.0,16.0,14.0,14.0,14.0,1.0,15.0,19.0,1.0,1.0,27.0,20.0,26.0,1.0,1.0,1.0,15.0,14.0,22.0,2.0,1.0,15.0,15.0,1.0,7.0,26.0,1.0,12.0,1.0,1.0,2.0,1.0,12.0,0.2184,15.0,1.0,22.0,21.0,15.0,11.0,15.0,24.0,0.0696,20.0,1.0,5.0,0.22,1.0,1.0,2.0,1.0,5.0,15.0,13.0,1.0,1.0,15.0,1680.0,1680.0,0.11244,1.0,1680.0,2.0,1.0,17.0,20.0,1.0))"
;
try{
REngine r = new JRIEngine() ;
r.parseAndEval( "morris <- function(...) list(...)" ) ;
r.parseAndEval( cmd ) ;
System.out.println( r.parseAndEval( "length(a)"
).asInteger() );
} catch( Exception e){
e.printStackTrace() ;
}
System.exit( 0 );
}
}
import org.rosuda.JRI.* ;
public class Morris {
public static void main(String[] args) {
String cmd = "a<-morris(model=NULL,factors=c(\"PecheAmateurs
décembre.proportionMetier\",\"PechePetitMetierMer
mai.proportionMetier\",\"PecheAmateurs mai.proportionMetier\",\"PecheChalutiere
janvier.minInactivityDays\",\"PechePetitMetierEtang
octobre.minInactivityDays\",\"PechePetitMetierEtang
décembre.minInactivityDays\",\"FiletMer.standardisationFactor\",\"PecheAmateurs
juin.minInactivityDays\",\"PechePetitMetierEtang
novembre.minInactivityDays\",\"PechePetitMetierMer
septembre.minInactivityDays\",\"PechePetitMetierMer
avril.minInactivityDays\",\"PecheAmateurs
août.proportionMetier\",\"PecheChalutiere
novembre.minInactivityDays\",\"PechePetitMetierMer
février.proportionMetier\",\"PecheChalutiere
juillet.minInactivityDays\",\"PechePetitMetierMer
octobre.proportionMetier\",\"CSar Groupe
5.reproductionRate\",\"PechePetitMetierMer
août.proportionMetier\",\"PechePetitMetierMer
janvier.minInactivityDays\",\"PechePetitMetierEtang
mai.minInactivityDays\",\"PecheAmateurs
octobre.minInactivityDays\",\"PecheAmateurs
septembre.minInactivityDays\",\"PecheChalutiere
juin.minInactivityDays\",\"PecheChalutiere
avril.minInactivityDays\",\"PecheAmateurs
juillet.proportionMetier\",\"PecheChalutiere
mai.minInactivityDays\",\"PechePetitMetierEtang
septembre.minInactivityDays\",\"PechePetitMetierMer
janvier.proportionMetier\",\"PecheAmateurs
septembre.proportionMetier\",\"PechePetitMetierEtang
février.minInactivityDays\",\"PechePetitMetierEtang
mars.minInactivityDays\",\"PechePetitMetierEtang
juillet.minInactivityDays\",\"PechePetitMetierMer
septembre.proportionMetier\",\"CSar.capturability\",\"PechePetitMetierMer
juin.proportionMetier\",\"PecheChalutiere
mars.minInactivityDays\",\"PecheChalutiere
septembre.minInactivityDays\",\"PecheAmateurs
janvier.minInactivityDays\",\"PechePetitMetierMer
août.minInactivityDays\",\"PechePetitMetierMer
juillet.proportionMetier\",\"PecheChalutiere
décembre.minInactivityDays\",\"PecheAmateurs
avril.minInactivityDays\",\"PecheAmateurs
mars.proportionMetier\",\"PechePetitMetierMer
novembre.minInactivityDays\",\"PechePetitMetierEtang
août.minInactivityDays\",\"CSar.recruitmentDistribution\",\"PecheChalutiere
février.minInactivityDays\",\"CSar.naturalDeathRate\",\"PecheAmateurs
octobre.proportionMetier\",\"PechePetitMetierMer
mai.minInactivityDays\",\"PechePetitMetierMer
mars.proportionMetier\",\"PecheAmateurs
août.minInactivityDays\",\"FiletEtang.standardisationFactor\",\"PecheChalutiere
août.minInactivityDays\",\"PecheAmateurs
janvier.proportionMetier\",\"PecheAmateurs
décembre.minInactivityDays\",\"PechePetitMetierEtang
avril.minInactivityDays\",\"PecheAmateurs
mars.minInactivityDays\",\"PechePetitMetierMer
décembre.minInactivityDays\",\"PecheAmateurs
mai.minInactivityDays\",\"PechePetitMetierEtang
juin.minInactivityDays\",\"Harpon.standardisationFactor\",\"PecheAmateurs
novembre.minInactivityDays\",\"PecheAmateurs
novembre.proportionMetier\",\"PechePetitMetierMer
mars.minInactivityDays\",\"Ligneemb.standardisationFactor\",\"PecheAmateurs
juin.proportionMetier\",\"PecheAmateurs
avril.proportionMetier\",\"PechePetitMetierMer
juillet.minInactivityDays\",\"PechePetitMetierMer
avril.proportionMetier\",\"PechePetitMetierMer
octobre.minInactivityDays\",\"PechePetitMetierMer
février.minInactivityDays\",\"PecheAmateurs
juillet.minInactivityDays\",\"PechePetitMetierMer
décembre.proportionMetier\",\"PecheAmateurs
février.proportionMetier\",\"PecheChalutiere
octobre.minInactivityDays\",\"CSar Groupe 4.reproductionRate\",\"CSar Groupe
7.reproductionRate\",\"Lignecote.standardisationFactor\",\"CSar.meanWeight\",\"CSar
Groupe 6.reproductionRate\",\"PechePetitMetierMer
juin.minInactivityDays\",\"PechePetitMetierMer
novembre.proportionMetier\",\"PechePetitMetierEtang
janvier.minInactivityDays\",\"PecheAmateurs
février.minInactivityDays\",\"CSar.growth\"),r=10,design=list(type=\"oat\",levels=c(5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5),grid.jump=c(2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2)),binf=c(0.0,0.0,0.0,11.0,10.0,12.0,0.06,10.0,11.0,0.0,0.0,0.0,10.0,0.0,11.0,0.0,1120.0,0.0,10.0,22.0,12.0,10.0,10.0,11.0,0.0,11.0,15.0,0.0,0.0,23.0,16.0,22.0,0.0,0.0,0.0,11.0,10.0,18.0,0.0,0.0,11.0,11.0,0.0,3.0,22.0,0.0,8.0,0.0,0.0,0.0,0.0,8.0,0.1456,11.0,0.0,18.0,17.0,11.0,7.0,11.0,20.0,0.0464,16.0,0.0,1.0,0.1515,0.0,0.0,0.0,0.0,1.0,11.0,9.0,0.0,0.0,11.0,1120.0,1120.0,0.0749,0.0,1120.0,0.0,0.0,13.0,16.0,0.0),bsup=c(1.0,1.0,1.0,15.0,14.0,16.0,0.09,14.0,15.0,2.0,2.0,1.0,14.0,1.0,15.0,1.0,1680.0,1.0,14.0,26.0,16.0,14.0,14.0,14.0,1.0,15.0,19.0,1.0,1.0,27.0,20.0,26.0,1.0,1.0,1.0,15.0,14.0,22.0,2.0,1.0,15.0,15.0,1.0,7.0,26.0,1.0,12.0,1.0,1.0,2.0,1.0,12.0,0.2184,15.0,1.0,22.0,21.0,15.0,11.0,15.0,24.0,0.0696,20.0,1.0,5.0,0.22,1.0,1.0,2.0,1.0,5.0,15.0,13.0,1.0,1.0,15.0,1680.0,1680.0,0.11244,1.0,1680.0,2.0,1.0,17.0,20.0,1.0))"
;
try{
Rengine r = new Rengine(new String[]{}, false, null ) ;
r.eval( "morris <- function(...) list(...)" ) ;
r.eval( cmd ) ;
System.out.println( r.eval( "length(a)" ).asInt() );
} catch( Exception e){
e.printStackTrace() ;
}
System.exit( 0 );
}
}
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel