[R] Verbatim text to file

Anders Nielsen anielsen at dina.kvl.dk
Thu Jun 13 15:05:06 CEST 2002


Dear R Gurus 

What is the elegant solution to the following problem?

Say I want to make a small java class from within an 
R-script and then copy the lines to a file. This may 
seem like an odd thing to do, but I am currently 
writing an R-package which is using the 'SJava' package 
from the Omegahat project, and this would be very 
helpful to supply stand-alone examples. 

Till now I have been using something like the following, 
but I would like to be able to paste the Java-code into 
the R-script directly.   

Thanks in advance, 

Anders.  

####R-snip 
   
  prog.string<-paste(
    "public class myiim implements IIModel{",
    "  public double[] drift(double[] val, double dt){return(new
double[]{0,0,dt});}",
    "  public double[] noise(double[] val, double dt){",
    "    return(new double[]{Math.sqrt(dt)*.1,Math.sqrt(dt)*.1, 0});",
    "  }",
    "  public int dim(){return(3);}",
    "  public double dist(){return(0.0);}",
    "}",
  sep="\n")
  cat(prog.string, file="myiim.java")



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list