Skip to content

Instantly share code, notes, and snippets.

@kuniyoshi
Created March 4, 2014 15:28
Show Gist options
  • Save kuniyoshi/9348544 to your computer and use it in GitHub Desktop.
Save kuniyoshi/9348544 to your computer and use it in GitHub Desktop.
A plotter.
-module(rstats).
-export([plot/1]).
-define(TMP_FILE, "/tmp/erlstats.data").
-define(R_FILE, "/tmp/erlstats.R").
plot(Points) ->
ok = file:write_file(?TMP_FILE,
[io_lib:format("~p~n", [X]) || X <- Points],
[write]),
Rprogram = ["erl <- read.table(\"", ?TMP_FILE, "\")", "\n",
"plot(erl$V1)", "\n",
"dev.off()\n"],
ok = file:write_file(?R_FILE, Rprogram, [write]),
os:cmd(["R CMD BATCH " | ?R_FILE]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment