From f09b518011c83e5a3ae261ec26c2972e2e8e2274 Mon Sep 17 00:00:00 2001 From: Philippe Veber Date: Wed, 21 Nov 2018 12:10:40 +0100 Subject: [PATCH] create utils library --- lib/utils/OCamlR_utils.ml | 22 ++++++++++++++++++++++ lib/utils/OCamlR_utils.mli | 14 ++++++++++++++ lib/utils/dune | 10 ++++++++++ 3 files changed, 46 insertions(+) create mode 100644 lib/utils/OCamlR_utils.ml create mode 100644 lib/utils/OCamlR_utils.mli create mode 100644 lib/utils/dune diff --git a/lib/utils/OCamlR_utils.ml b/lib/utils/OCamlR_utils.ml new file mode 100644 index 0000000..babda68 --- /dev/null +++ b/lib/utils/OCamlR_utils.ml @@ -0,0 +1,22 @@ +open OCamlR +open OCamlR_wraputils +open OCamlR_base + +module Stubs = OCamlR_utils_stubs + +let data ?envir name = + R.eval (R.symbol "data") [ + R.arg R.string name ; + R.opt Environment.r "envir" envir ; + ] + |> ignore + +let write'table ?file ?sep ?col'names ?row'names ?quote x = + Stubs.write'table + ?file:(file |?> R.string) + ?sep:(sep |?> R.string) + ?col'names:(col'names |?> R.bool) + ?row'names:(row'names |?> R.bool) + ?quote:(quote |?> R.bool) + ~x:(Dataframe.r x) () + |> ignore diff --git a/lib/utils/OCamlR_utils.mli b/lib/utils/OCamlR_utils.mli new file mode 100644 index 0000000..431d7de --- /dev/null +++ b/lib/utils/OCamlR_utils.mli @@ -0,0 +1,14 @@ +open OCamlR_base + +val data : + ?envir:Environment.t -> + string -> unit + +val write'table : + ?file:string -> + ?sep:string -> + ?col'names:bool -> + ?row'names:bool -> + ?quote:bool -> + Dataframe.t -> + unit diff --git a/lib/utils/dune b/lib/utils/dune new file mode 100644 index 0000000..97b4f6f --- /dev/null +++ b/lib/utils/dune @@ -0,0 +1,10 @@ +(library + (name OCamlR_utils) + (public_name ocaml-r.utils) + (wrapped false) + (libraries ocaml-r.base ocaml-r.wraputils)) + +(rule + (targets OCamlR_utils_stubs.ml) + (deps (:exe ../../stubgen/stubgen.exe)) + (action (with-stdout-to %{targets} (run %{exe} utils))))