Skip to content

Commit

Permalink
create utils library
Browse files Browse the repository at this point in the history
  • Loading branch information
pveber committed Nov 21, 2018
1 parent a76a361 commit f09b518
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/utils/OCamlR_utils.ml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions lib/utils/OCamlR_utils.mli
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions lib/utils/dune
Original file line number Diff line number Diff line change
@@ -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))))

0 comments on commit f09b518

Please sign in to comment.