scicloj / clojisr

Clojure speaks statistics - a bridge between Clojure to R
https://scicloj.github.io/clojisr/
Eclipse Public License 2.0
150 stars 10 forks source link

Add optional convert options for r->clj functions #105

Open behrica opened 4 months ago

behrica commented 4 months ago

as discussed here: https://clojurians.zulipchat.com/#narrow/stream/224816-clojisr-dev/topic/native.20support.20.20for.20tech.2Ev3.2Edataype.20tensors.20.3F/near/438179471

behrica commented 1 week ago

I don't remember any more about the details of the code changes. The "goal" is still to be able later to implement this:

(require-r-package '[datasets])
(r->clj r.datasets/iris {:as-tensor true})

so we can offer options to change the build-in conversions.

behrica commented 1 week ago

@genmeblog I have a first versin of a working conversion to tensor. See here for test: https://github.com/scicloj/clojisr/blob/79866c2ffb5a12c2b6f3904ad6525c95336e2d16/src/clojisr/v1/r.clj#L242

Maybe have a quick look at the flow of the "options"

behrica commented 1 week ago

I have not checked if the "order" of elements is correct.

behrica commented 1 week ago

I have the impression that this ns tech.v3.tensor.dimensions

contains the right functions to "convert" in one go from the "matrix data as seq" as we get it from (prot/->clj exp) into the tensor....

behrica commented 1 week ago

@genmeblog I noticed that for R arrays we alreday get a flat vector from REngine. Is it somehwere documented whats the order of this is in case of multidimensional arrays ?

behrica commented 1 week ago

For reference: https://cran.r-project.org/web/packages/reticulate/vignettes/arrays.html