3 ms·
Context ctx = Context.newBuilder("R").allowAllAccess(true).build(); Value rFunction = context.eval("R", "function(table) { " + " table <-
by tofflos 8y ago
Context ctx = Context.newBuilder("R").allowAllAccess(true).build();
Value rFunction = context.eval("R",
"function(table) { " +
" table <- as.data.frame(table);" +
" cat('The whole data frame printed in R:\n');" +
" print(table);" +
" cat('---------\n\n');" +
" cat('Filter out users with ID>2:\n');" +
" print(table[table$id > 2,]);" +
"}");
User[] data = getUsers();
rFunction.execute(new UsersTable(data));
The example above combined with "JEP 326: Raw String Literals" and an IDE that understands Java with embedded R code would be cool to play with.