Org-mode and julia: an introduction
Table of Contents
1 What you need to get started
(load "~/gitm/projects/ob-julia.el") (org-babel-julia-initiate-session "*julia*" nil)
rand(9)
9-element Float64 Array: 0.683697 0.115187 0.65871 0.126754 0.296551 0.117243 0.952961 0.74621 0.92133
1.1 Julia
- First install takes the longest, later updates not so bad.
- all the dependencies
1.2 Add on packages
Based on The State of Statistics in Julia by John Myles White.
Pkg.add("DataFrames", "Distributions", "MCMC", "Optim", "NHST", "Clustering")
Pkg.add("RDatasets")
This one is pretty big.
1.2.1 Winston
Pkg.add("Winston")
This one has lots of dependencies.
1.2.2 Gadfly
Pkg.add("Gadfly")
- packages take a lot longer to load than R
1.3 ESS
http://stat.ethz.ch/ESS/index.php?Section=download
rand(9) print("hello")
9-element Float64 Array: 0.914156 0.489364 0.840862 0.389737 0.914611 0.398722 0.298391 0.592467 0.0428432 hello
(add-to-list 'load-path "~/path/to/ESS/lisp") (require 'ess-site)
1.4 Org-mode
(setq inferior-julia-program-name "~/path/to/julia-release-basic")
(org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t) (julia . t)))
For inline image display
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images) (add-hook 'org-mode-hook 'org-display-inline-images)
2 Getting started
[3:50] x = [3:6] y = [5:11] z = [4:7] x + z ans sum(x) mean(x) exp(x) log(x) sort(x) sqrt(x) diff(x) x[3] y[2:4] typeof(x) 1.0 1. Inf -Inf NaN true false 1 + 2im
3 Plotting with Winston
using Winston x = linspace( 0, 3pi, 100 ) c = cos(x) s = sin(x) p = FramedPlot(); setattr(p, "title", "title!") setattr(p, "xlabel", L"\Sigma x^2_i") setattr(p, "ylabel", L"\Theta_i") add(p, FillBetween(x, c, x, s) ) add(p, Curve(x, c, "color", "red") ) add(p, Curve(x, s, "color", "blue") ) file(p, "blah2.png")
4 Plotting with Gadfly
using RDatasets using Gadfly using Compose iris = data("datasets", "iris") p = plot(iris, {:x => "Sepal.Length", :y => "Sepal.Width"}, Geom.point); SVG("iris_plot.svg", 6inch, 4inch)