Git Product home page Git Product logo

jl4r's Introduction

Julia for R

This is an attempt to embed the julia language in R. Actually, very basic julia types are converted to R objects (DataFrame coming soon!).

Install

Clone this git and in the parent directory:

R CMD INSTALL jl4R

Test

First, in a terminal or in your .bashrc (or equivalent):

export JLAPI_HOME=<your julia home>

Then, the R console:

require(jl4R)			# => true
.jl('LOAD_PATH')	# => [<your julia home>/local/share/julia/site/v0.2", "<your julia home>/share/julia/site/v0.2"]

If the last result is unexpected, see the Troubles section.

Example

require(jl4R)
# no need .jlInit() since automatically called once
.jl('using RDatasets') # A bit slow, julia and RDatasets initializations
a<-.jl('iris=data("datasets","iris")') # yes, it is a bit weird, but it is for testing!
.jl(vector(iris[2]))

# a is then an R object
a

# another call
.jl('colnames(iris)')

# a plot should work too!
plot(.jl('vector(iris[1])')~.jl('vector(iris[2])'))

Troubles

  1. htableh.inc in src/support directory is missing (copy it in include/julia of your julia directory). Update: htableh.inc is now in the package (src/jl4R) until the julia core solve the problem.

  2. For linux user, you should also put jl_bytestring_ptr in julia.expmap.

  3. If (like me, on MacOSX) the result of the previous test is wrong, the reason may come from the fact that in the initialization of julia libpcre is required and failed to be loaded properly. Then, set

     LD_LIBRARY_PATH=<your julia home>/lib/julia
    

If you don't want to set LD_LIBRARY_PATH, alternate solution would be:

change the base/client.jl file as follows:

split init_load_path into 2 functions

	function init_load_path()
		vers = "v$(VERSION.major).$(VERSION.minor)"
		
		global const DL_LOAD_PATH = ByteString[
			join([JULIA_HOME,"..","lib","julia"],Base.path_separator)
		]
		
		global const LOAD_PATH = ByteString[
			abspath(JULIA_HOME,"..","local","share","julia","site",vers),
			abspath(JULIA_HOME,"..","share","julia","site",vers)
		]
	end

Notice that abspath is not used in the definition of DL_LOAD_PATH (since libpcre is required by abspath which depends of DL_LOAD_PATH needed by dlopen). Of course, DL_LOAD_PATH depends on the definition of JULIA_HOME (supposed to be here: "your julia home"/lib) which normally is related to the location of sys.ji. In such a case, you can install the R package.

jl4r's People

Contributors

lgautier avatar rcqls avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.