• Stars
    star
    142
  • Rank 250,811 (Top 6 %)
  • Language
    HTML
  • License
    Eclipse Public Li...
  • Created almost 5 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Clojure speaks statistics - a bridge between Clojure to R

ClojisR

Clojure speaks statistics - a jisr between Clojure and R

Clojars Project

How to pronounce it?

The beginning of the pronunciation is the same as Clojure, but then it rhymes with 'kisser'. Actually, the last vowel is nonexistent, so you may try to pronounce it with less movement between s and r, like 'yesssr!'.

Status

  • still evolving
  • not recommended for production yet
  • already used by several people in their data science explorations

Clojurists Together

Hurray!

We are happy to announce that ClojisR is selected by Clojurists Together in Q4 2020! Expect more information soon.

Scope of the project

Libraries for Clojure-R interop are not new - see this list.

This project suggests yet another way to use R from Clojure.

Currently we target only JVM Clojure, but we are interested in generalizing the work to Clojurescript.

The related problem, of calling Clojure from R, may be addressed too in the future. We are experimenting with that.

Meta Goals

  • Realize what is essential for Clojure to become a beginner-friendly solution for data science.

  • Expose the Clojure ecosystem to a different culture and to more diverse groups of users/programmers.

Technical Goals

  • A Function-centric API, where the default mode of usage is calling R functions on R objects, from Clojure (Status: supported)

  • "R code as Clojure data", inspired by the EDN-based syntax inroducted in gg4clj and used in huri (Status: supported)

  • Interop with minimal copying of data (Status: supported)

  • Compatibility with common data abstractions such as tech.ml.dataset datasets (Status: partially supported)

  • Convenient wrappers for common use cases, such as visualization (Status: basic support for plots and Rmarkdown)

  • Abstraction over different runtimes (GNUR R, Renjin, FastR) (Status: GNU R is supported through Rserve; Renjin has some basic support, moved to a separate library ClojisRenjin)

  • Convenient multi-session support (Status: basic support with some known issues)

Usage requirements

  • Linux, MacOS or WSL (Windows Subsystem for Linux)
  • JDK 1.8 or later
  • Clojure 1.9.0 or later
  • R
  • The Rserve R package (install.packages("Rserve",,"http://rforge.net")) Tested with Rserve version 1.8.6. Earlier versions are known to have a bug.
  • This library: Clojars Project

MacOS installation

Installing R with Rserve on MacOS can be problematic due to issues related to openssl installation. Please apply following steps (thanks to @ezmiller):

  1. Download the lastest R for mac from here: https://cloud.r-project.org/
  2. Install openssl: brew install openssl.
  3. Make sure that the openssl library is linked. Try in order:
    • brew link --force openssl
    • If that doesn't work, follow directions in brew info openssl for setting environment variables. Set the LIBRARY_PATH environment variable to the location of the library, e.g. export LIBRARY_PATH=/usr/local/opt/[email protected]/lib.

Setting up the logging

  • clojisr library uses clojure/tools.logging for logging. tools.logging doesn't force any logging backend and users have to configure it on their side. To force specific backend you can set it using JVM options, for example in lein profile.clj or project.clj:
:jvm-opts ["-Dclojure.tools.logging.factory=clojure.tools.logging.impl/jul-factory"]

Docker image

Thanks to Carsten Behring we have a Docker template prepared

https://github.com/behrica/clj-py-r-template

The Dockerfile of the template adds as well python + libpython-clj for completeness.

So it has in a single place all dependencies and they do work together and no further setup is required.

Checking if it works

This should work for you (assuming you have the clj tool):

$ clj -Sdeps '{:deps {scicloj/clojisr {:mvn/version "1.0.0-BETA20"}}}'
Clojure 1.10.1
user=> (require '[clojisr.v1.r :refer [r]])

user=> (r '(+ 1 2))
[1] 3

Known issues

  • clojisr can behave in a strange way when abandoned R (with Rserve) processes are running. Please kill such processes before creating an Rserve session.
  • Nextjournal can hang due to problems with logging, please add org.slf4j/slf4j-nop {:mvn/version "1.7.30"} to the deps to disable logger.

Video presentations

The main ideas were discussed at Scicloj Web meeting #7 and ClojuTRE 2019.

Note however that:

  • The API has changed since then (code generation mechanism, data visualization support, printing - see the Tutorials below).
  • On the meeting, there is some careless use of the term 'zero copy'. Actually, what is usually meant by this term is not supported at the moment.

Tutorials

Background

  1. Lisp for statistical computing

  2. Calling R from Clojure: existing libraries

  3. R backends

  4. Some of R's data abstractions

  5. Clojure's counterparts of R's data abstractions

Choices of the current project

Here are the current priorities of the project in some central design and implementation questions.

Future opportunities

Here are some possible future developments we are considering.

Discussion

Please share your comments, thoughts, ideas and questions at the Issues Page of this project and at the r-interop stream of the Clojurians Zulip.

Also we run a stream for developers or people interested in contributing.

Testing

The code tests are embedded in the tutorials and are run when they are rendered (using notespace). This way we make sure that tests and documentation are in sync.

Tools used

Working on this project, we enjoyed the following tools (partial list):

  • In early versions, hara.test was used for automated docstrings by tests. We may come back to using it.

  • clj-kondo for code quality control

  • notespace for documentation and tests

License

Copyright Β© 2019-2020 Scicloj

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.

More Repositories

1

tablecloth

Dataset manipulation library built on the top of tech.ml.dataset
HTML
268
star
2

scicloj.ml

A Clojure machine learning library
Clojure
200
star
3

notespace

using your namespace as a notebook
Clojure
146
star
4

clay

A tiny Clojure tool for dynamic workflow of data visualization and literate programming
CSS
100
star
5

clojure-data-cookbook

A book about how to do common data manipulation, analysis, and visualization tasks in Clojure
Clojure
74
star
6

wolframite

An interface between Clojure and Wolfram Language (the language of Mathematica)
Mathematica
39
star
7

scicloj-data-science-handbook

Clojure data science handbook - journal style examples of data science
Clojure
34
star
8

metamorph

Context pipelines
Clojure
31
star
9

clj-djl

clojure wrap for deep java library(DJL.ai)
Clojure
31
star
10

sklearn-clj

Plugin to use sklearn models in metamorph.ml
Clojure
28
star
11

viz.clj

A Clojure data visualization library
Clojure
27
star
12

noj

A clojure framework for data science
Clojure
25
star
13

scicloj.ml-tutorials

Tutorials for scicloj.ml
Clojure
22
star
14

kindly

A small library for defining how different kinds of things should be rendered
Clojure
20
star
15

wadogo

scales for clojure
Clojure
18
star
16

metamorph.ml

Machine learning functions for metamorph based on machine learning pipelines
Clojure
18
star
17

tablecloth.time

Tools for the processing and manipulation of time-series data in Clojure.
Clojure
16
star
18

tutorials

A repo for hosting Clojure data science tutorials created by the community
Jupyter Notebook
15
star
19

nov2021-workshops

The November 2021 pre-conference workshops of re:Clojure
Clojure
14
star
20

scicloj.ml.smile

A Smile plugin for scicloj.ml
Clojure
8
star
21

notespace-sicmutils-example

An example of using Notespace to write Sicmutils notes
Clojure
8
star
22

clojure-data-scrapbook

community-contributed examples for the emerging Clojure data stack
Clojure
8
star
23

scicloj.ml.xgboost

A xgboost plugin for scicloj.ml
Clojure
7
star
24

scicloj.ml.tribuo

Use Tribuo ML model in metamorph.ml
Clojure
7
star
25

cjlpy

Using Python from Clojure
Clojure
6
star
26

clojisr-examples

examples of using clojisr
Clojure
6
star
27

ml-study

A repo for the ml study group
HTML
5
star
28

fastr-examples

Experimenting with Clojure-FastR interop
Clojure
5
star
29

visual-tools-experiments

Experiments of the visual tools group
HTML
5
star
30

scicloj.ml.top2vec

Use top2vec model from Clojure
Clojure
4
star
31

clay.el

Emacs bindings for the Clojure Clay tool
Emacs Lisp
4
star
32

scicloj.github.io

The Scicloj website
HTML
4
star
33

docker-hub

docker containers
Dockerfile
4
star
34

python-data-science-handbook-in-clojure

A Clojure port of the code in the Python Data Science Handbook
Clojure
4
star
35

cmdstan-clj

Using the Stan statistical modelling language from Clojure using the CmdStan CLI
Clojure
4
star
36

scicloj.old.replaced-20220218

Source of the old Scicloj website (replaced by scicloj.github.io, 2022-02-18)
HTML
3
star
37

kind-clerk

An adapter for the Clerk tool to support the Kindly conventions
Clojure
3
star
38

kindly-noted

A common space for notes following the Kindly convention
Clojure
3
star
39

tempfiles

a small Clojure library for managing temporary files
Clojure
3
star
40

kind-portal

An adapter for the Portal tool to support the Kindly conventions
Clojure
3
star
41

sicmutils-drafts

Drafts of notes about Sicmutils
Clojure
2
star
42

gandiva-examples

Trying Gandiva from Clojure
Clojure
2
star
43

kaggle-kernels

Implementing kernels for some kaggle competetions
Clojure
2
star
44

tensorflow-study

studying tensorflow and its use from Clojure
2
star
45

ds4clj

data science for clojure devs course
2
star
46

TensorStandardInterface

An effort towards an idiomatic Clojure interface for Tensors (N-Dimensional Arrays).
Clojure
2
star
47

metamorph-examples

Clojure
2
star
48

scicloj.github.com.archived-20220218

Scicloj website - an old version
HTML
1
star
49

workshops

1
star
50

sci-fu

The main repo for the Scicloj Foundations study group
Jupyter Notebook
1
star
51

scicloj.ml.clj-djl

clj-djl models for metamorph.ml and scicloj.ml
Clojure
1
star
52

clojisr-rengine

Just a wrapper to the newest REngine source code
Shell
1
star
53

datarium-CSV

datasets from the datarium R package, converted to CSV format
R
1
star
54

workplan

The SciCloj workplan -- a living organizing document
1
star
55

kindly-advice

a small library to advise Clojure data visualization and notebook tools how to display forms and values, following the kindly convention
Clojure
1
star
56

note-to-test

generating tests automatically from Clojure notes
Clojure
1
star