Get Started
👋 Hi and welcome to Nextjournal!
Use this notebook to play around and familiarize yourself with the Nextjournal editor. Here are some things you can try out:
Inserting content
Next to typing text into Nextjournal, you can use the + buttons that appear between nodes to insert different types of content. Try it for yourself.
Referencing and inspecting files
Here is a CSV file that contains housing prices that we uploaded to this article. You can upload files by simply dragging them into the editor window or by clicking the + button and selecting "File".
What follows is an R code cell that references the uploaded file and reads it into a housing
variable that is used later to create a plot. You can reference files by selecting code in a code cell and click the + button in the popup menu or by pressing Cmd/Ctrl+E
.
library("tidyverse") housing <- read_csv(housing-prices.csv) housing
Now if you run the above code cell (by clicking the play button or hitting Shift+Enter
), you’ll see that it shows you the contents of the housing
variable as table.
Plotting some data
In the previous code cell, we imported a library called tidyverse
which comes with ggplot2
, a tool for creating plots. We will use it to create a very basic scatter plot of housing prices over time for Massachusetts (MA
) and Texas (TX
). All the data comes from the previously defined housing
variable. Run the code cell to see for yourself:
ggplot(filter(housing, State %in% c("MA", "TX")), aes(x=Date, y=Home.Value, color=State)) + geom_point()
We could do plenty to make this plot much nicer looking but why not play around with it a bit for yourself?
Working with other languages
Nextjournal is not restricted to R and plotting. In fact, you can use multiple different programming languages in the same notebook!
The next code cell shows how you can install a package using a Bash cell (in this case svgwrite
) and how to use a Python cell to create a nice looking dot pattern:
pip install svgwrite
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()
That’s it for now! There’s a lot more that Nextjournal can do so we suggest that you, once you’re done experimenting here, head over to our Help page and see what else you find interesting.
Running into trouble? You can reach out to us anytime and we’ll help you out.