In the beginning, there was text… and it was good.
We didn’t have need for high falutin rich text hypermedia science fiction mumbo jumbo. At its core, org-mode is just exactly this: text. Org-mode may be daunting, but when you feel overwhelmed, breathe and know that org-mode’s lowest common denominator is just plain text.
Sometimes, however, text alone doesn’t adequately convey intent. Occasionally we need to be bold or otherwise add emphasis to words in order to underscore their importance. If you’ve ever used the young upstart, Markdown (oops, there’s a link), then you’re already familiar with the general concept of lightweight text mark-up. In general, anything Markdown can do, org-mode can do better. But we’re getting ahead of ourselves.
Text styles are one matter, but text structure is another. The mother of all structural elements is the title. Let’s add one now:
Don’t worry that we got to the title a little late. If we decide to publish this document, org-mode knows where to put titles.
Next up are:
When using headers, be judicious. While org-mode supports obscene levels of nesting, you you’re better off with fewer levels of nesting. Edward Tufte likes to point out that Richard Feynman was able to write about most of physics without resorting to more than two levels of nesting.
column | another column | columns for days |
---|---|---|
foo | bar | baz |
spam | spam | spam |
Can use tables as spreadsheets, which is an epic hack, but I dislike spreadsheets, so I don’t really use this.
Yes! In a src block…. and we can run it, just like in Jupyter! We specify that we’re writing python code here.[fn:: org-mode supports LOTS of languages (http://orgmode.org/worg/org-contrib/babel/languages.html)]
from sys import version
return("Hello, org-mode from Python " + version)
Depending on the language, you might have to tell org-mode whether we’re looking for output of the code, or whether to inter a value (that’s the default, but we could also capture printed output).
Let’s capture that result in a variable by naming our code block.
MEANING_OF_LIFE = 42
return(MEANING_OF_LIFE)
It seems fitting that we defined the meaning of life in Python, am I right Python fans? Now that we know the meaning of life, we can do something with it in R. Here we create a numeric vector starting with 1 and ending with the meaning of life.
1:meaning_of_life
ls -s --block-size=K /bin |
tail -n +2
Here we can strip out the annoying “K” from our directory listing. Can’t figure out what datatype to return? Org-mode is written in emacs-lisp, and lisp originally meant “list processing.” Therefore, lists are generally a good bet :-p
import pandas as pd
df = pd.DataFrame(dir_listing)
df[0] = df[0].replace({'K': ''}, regex=True)
return(df.values.tolist())
library(ggplot2)
names(munged_df) <- c("kilobytes", "filename")
print(ggplot(munged_df, aes(x=kilobytes)) + geom_histogram())