Sujet : Fun: R on VMS De : arne (at) *nospam* vajhoej.dk (Arne Vajhøj) Groupes :comp.os.vms Date : 02. Sep 2024, 19:43:56 Autres entêtes Organisation : A noiseless patient Spider Message-ID :<vb511c$2ur8c$1@dont-email.me> User-Agent : Mozilla Thunderbird
$ type demo.r x = rnorm(10, mean=0, sd=1) print(x) mx = mean(x) print(mx) $ rr demo.r [1] 0.07825535565335 0.26473517575753 0.24130353303532 0.93891048091823 [5] -0.28034267101425 -1.39355828984642 -0.02804756791571 -0.04600998611413 [9] -1.7059928439304 0.69180273192578 [1] -0.12389440815307 $ sh symb rr RR == "@RR" $ type rr.com $ java -cp .:renjin-script-engine-3.5-beta76-jar-with-dependencies.jar "RR" 'p1' $ exit $ type RR.java import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import javax.script.ScriptException; import org.renjin.script.RenjinScriptEngine; public class RR { private static String load(String fnm) throws IOException { StringBuilder sb = new StringBuilder(); BufferedReader br = new BufferedReader(new FileReader(fnm)); String line; while((line = br.readLine()) != null) { sb.append(line + "\n"); } br.close(); return sb.toString(); } public static void main(String[] args) throws IOException, ScriptException { if(args.length == 1) { try { String src = load(args[0]); RenjinScriptEngine eng = new RenjinScriptEngine(); eng.eval(src); } catch(Exception ex) { ex.printStackTrace(); } } else { System.out.println("Usage: rr <r-source-file>"); } } } It would obvious be better if Renjin command line worked, but for some reason it does not work on VMS. So I wrote a little wrapper reading the file and evaluating using the embedded Renjin engine. Arne