Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Collaborative Coding with Emacs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Data Literacy - RDM
workshops
Collaborative Coding with Emacs
Commits
bfb3ca4a
Commit
bfb3ca4a
authored
1 year ago
by
Jonathan Hartman
Browse files
Options
Downloads
Patches
Plain Diff
Started a section on code cells
parent
4434b71b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lia/nfdi-emacs-lia-workshop.lia.md
+65
-2
65 additions, 2 deletions
lia/nfdi-emacs-lia-workshop.lia.md
with
65 additions
and
2 deletions
lia/nfdi-emacs-lia-workshop.lia.md
+
65
−
2
View file @
bfb3ca4a
...
...
@@ -45,6 +45,10 @@ Let’s make an executive summary of org-mode:
Org-mode is a magnificent tool when it comes to reproducible research [^1], since this combines a
well documented way of analysing a data set.
By combining org-mode with code, we can create a document which not only describes and explains
a process or analysis in the style of literate programming, but also can be automatically run to
generate nicely formatted files run on the most recently available data.
[
^1
]:
Stanisic,
Luka, and Arnaud Legrand. 2014. “Effective Reproducible Research with Org-Mode
and Git.” In /Euro-Par 2014: Parallel Processing Workshops/, edited by Luís Lopes, Julius
Žilinskas, Alexandru Costan, Roberto G. Cascella, Gabor Kecskemeti, Emmanuel Jeannot, Mario
...
...
@@ -56,8 +60,67 @@ Cannataro, et al., 475–86. Cham: Springer International Publishing.
### How to write a Code Cell
-
syntax
-
optional parameters
Code blocks in org-babel always start and end the same way:
```
#+BEGIN_SRC <language>
#+END_SRC
```
We can also add plenty of metadata before the block:
-
`#+NAME`
Provides the block with a name, so that we can easily reference it from other code cells
-
`#+CAPTION`
Provide a caption under the cell when the document is exported
There are also switches we can add after the language that affect how the cell is executed or
processed:
-
`:results`
Controls how the results of the code execution are handled.
-
`:results output`
outputs the results of the cell in the document
-
`:results silent`
supresses all output from the cell
-
`:results file`
creates a file to contain the output
-
`:exports`
Controls how the code block itself is treated in the document.
-
`:exports code`
includes the code block itself in the document
-
`:exports results`
supresses the code, but shows any results generated by the code
-
`:exports both`
includes both the code and the results in the document
-
`:eval`
-
`:eval yes`
The code cell will be evaluated when the document is exported
-
`:eval no`
The code cell will not be evaluated when the document is exported. You might use
this when
-
`:eval no-export`
The code will not be evaluated when exporting, but will execute within the
org-mode buffer
-
`:tangle yes`
The code in this block will be "tangled" (extracted) into a seperate source file.
This could be useful if you are documenting how to create a script and part of the result of the
document is the final script itself.
There are some additional switches we can add that are specific to the language used in the cell.
For example:
-
In Python or R, we can use the
`:session <name>`
switch to ensure more than one code block share
a session
-
In R, we can use
`:colnames yes`
or
`:colnames no`
to dictate whether or not column names should
appear in the results. There is a similar switch called
`:rownames`
### Variables
We can use
`var=<value>`
to set a variable that will be available in the code block. This variable
can either be a constant or a reference to another cell's
`#+NAME`
, in which case the value of the
variable will be set to whatever the result of that cell is.
# Preparing Data
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment