Commit 55b810be authored by G. Jay Kerns's avatar G. Jay Kerns

flesh out ob-doc

parent c10d6ae8
This diff is collapsed.
No preview for this file type
% Created 2013-02-27 Wed 22:41
\author{G. Jay Kerns}
\title{Org-mode and julia: an introduction}
pdfcreator={Generated by Org mode 7.9.3f in Emacs}}
One of the reasons for this document is that I wanted to make it easier to get acquainted with \texttt{julia}.
\section[What you need to get started]{What you need to get started}
This document assumes you have at least a passing familiarity with Org-mode and Emacs keybindings.
(load "/path/to/ob-julia.el")
(org-babel-julia-initiate-session "*julia*" nil)
\item[Note:] a lot of the code blocks below have the header argument \texttt{:eval no-export} which means that the code block can be evaluated interactively in this session by \texttt{C-c C-c} with point in the code block but will \emph{not} be evaluated during export. The reason is that those blocks have settings which conflict with my current setup but would be useful for others going through this document.
\item First install takes the longest, later updates not so bad.
\item all the dependencies
\subsection[Add-on packages]{Add-on packages}
Based on \href{}{The State of Statistics in Julia} by John Myles White.
Pkg.add("DataFrames", "Distributions", "GLM", "MCMC", "Optim",
"NHST", "Clustering")
\item Winston
The most stable and fully featured of the \texttt{julia} graphics packages at the time of this writing appears to be the \texttt{Winston} package, among alternatives including \texttt{Gadfly}.
The Winston package has lots of dependencies and many of them must be built from source (on Ubuntu).
\item Gadfly
\item packages take a lot longer to load than R
This document assumes that you have at least a passing familiarity with org-mode such that you likely have something like the following already in your \texttt{.emacs}:
(require 'org)
Another handy setting to have is
(setq org-confirm-babel-evaluate nil)
In order to run this org file you will need to load \texttt{ob-julia.el} at some point. One way is to edit the following code block and then \texttt{C-c C-c} with point inside the block:
(load "/path/to/ob-julia.el")
(org-babel-julia-initiate-session "*julia*" nil)
The first command loads the \texttt{ob-julia.el} file and the second initiates a \texttt{julia} session in a buffer called \texttt{*julia*}. An alternative method is to put the following in your \texttt{.emacs} (these should go below the \texttt{(require 'org)} line):
(add-to-list 'load-path "/path/to/ob-julia.el")
'((emacs-lisp . t)
(julia . t)))
The following lines (either here or in your \texttt{.emacs}) allow for inline image display in the Emacs buffer.
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
(add-hook 'org-mode-hook 'org-display-inline-images)
If you'd like to do \LaTeX{} export then put the following in your emacs.
(require 'ox-latex)
(require 'ox-beamer)
\subsection[ESS - Emacs Speaks Statistics]{ESS - Emacs Speaks Statistics}
The place to get the latest version of ESS is \href{}{here}.
(add-to-list 'load-path "/path/to/ESS/lisp")
(require 'ess-site)
(setq inferior-julia-program-name "/path/to/julia-release-basic")
\section[Fitting (generalized) linear models]{Fitting (generalized) linear models}
using RDatasets, DataFrames, Distributions, GLM
trees = data("datasets", "trees");
treeslm = lm(:(Girth ~ Height + Volume), trees);
Warning: New definition show(Any,LmMod) is ambiguous with show(IO,ANY) at show.jl:6.
Make sure show(IO,LmMod) is defined first.
Warning: New definition show(Any,GlmMod) is ambiguous with show(IO,ANY) at show.jl:6.
Make sure show(IO,GlmMod) is defined first.
WARNING: strcat is deprecated, use string instead.
WARNING: qrd is deprecated, use qrfact instead.
3-element Float64 Array:
3x4 DataFrame:
Estimate Std.Error t value Pr(>|t|)
[1,] 10.8164 1.9732 5.48165 7.44691e-6
[2,] -0.0454835 0.0282621 -1.60935 0.118759
[3,] 0.19518 0.0109553 17.8161 8.2233e-17
\section[Installation prerequisites]{Installation prerequisites}
\section[Interactive session evaluation]{Interactive session evaluation}
This is about ESS.
\section[Evaluation inside the Org buffer]{Evaluation inside the Org buffer}
\subsection[:results value]{:results value}
\subsection[:results output]{:results output}
\subsection[Plotting with Winston]{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, "example1.png")
\subsection[Plotting with Gadfly]{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)
\section[Exporting to other formats]{Exporting to other formats}
\section[Other things]{Other things}
\item empty lines in output for semicoloned lines
\item need to start session first
\item when :results value be careful because of readcsv
\item characters
\item 1x1 matrix
% Generated by Org mode 7.9.3f in Emacs
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment