by Martin KavalarFeb 27 2019
Making science reproducible @nextjournal

👋 Nextjournal

Welcome to this quick introduction to Nextjournal.

1.
Introduction

Remixing enables effortless reuse and sharing.

2.
Working with Code & Data

2.1.
Basics

randn(500)

2.2.
Accessing Files

Passagiere S-Bahn Hamburg 2009.csv
library(tidyverse)
read_csv2(Passagiere S-Bahn Hamburg 2009.csv) %>% 
  group_by(Station) %>% 
  summarize(Einsteiger= sum(Einsteiger)) %>%
	top_n(10) %>% 
	ggplot(aes(Station, Einsteiger, fill=Station)) +
		geom_bar(stat = "identity") +
		scale_y_continuous(labels = scales::comma) +
		theme(axis.text.x=element_blank(), axis.ticks.x=element_blank(),
          plot.title = element_text(hjust = 0.5)) +
		ggtitle("Top 10 Stations S-Bahn Hamburg 2009")

2.3.
JavaScript

For instant feedback.

var size = 1-, x = [], y = [], z = [], i, j;

for (var i = 0; i < size; i++) {
	x[i] = y[i] = -2 * Math.PI + 4 * Math.PI * i / size;
  z[i] = new Array(size);
}
for (var i = 0; i < size; i++) {
	for (j = 0; j < size; j++) {
		var r2 = x[i] * x[i] + y[j] * y[j];
    z[i][j] = Math.sin(x[i]) * Math.cos(y[j]) * Math.sin(r2) / Math.log(r2+1);
 	}
}

Nextjournal.plot([{ z: z, x: x, y: y, type: 'contour' }]);

2.4.
Reusing Custom Environments

import math
import random
import svgwrite

dots, c, size, w, h = 3000, 6.1, 4, 670, 150
phi = (1 + math.sqrt(5)) / 2
rad_phi = (math.pi * 2) / (phi + 1)
dwg = svgwrite.Drawing("/results/spiral.svg", (w, h))
a = 0
for n in range (0, dots):
  r = c * math.sqrt(n)
  x = r * math.cos (a) + w / 2
  y = r * math.sin (a) + h / 2
  color = "#%06x" % random.randint(0, 0xFFFFFF)
  dwg.add(dwg.circle ((x, y), size, fill=color))
  a += rad_phi
dwg.save()

2.5.
Installing Dependencies

2.6.
Building Custom Environments

3.
Versioning

Notebooks are fully versioned including referenced data files, results and environments.

4.
Importing

4.1.
Files

4.2.
Notebooks (Jupyter / Markdown / RMarkdown)

Let's import something from a gallery of interesting Jupyter Notebooks.

4.3.
Docker Images

Bash Official
Download as Docker image from:
This image was imported from: bash
head -n 2 /etc/os-release

4.4.
GitHub Repositories

ls /demo

4.5.
Data (Amazon S3 / Google Cloud Storage)

nextjournal-maven
Public
ls /nextjournal-maven

5.
Exporting

5.1.
Markdown

5.2.
Data

5.3.
Docker Images

6.
Sharing