This article covers some basic functions within R, showing you how to get started working with it on the Nextjournal platform. Links are provided to more in-depth documents covering specific topics and the platform itself.
Add to an article using the Insert Menu, which appears when you click the 'Add new content' button, the +-line that appears when hovering the cursor between article content, or when you hit the Return key twice at the end of a text paragraph. Code cells are language-specific—we'll add an R cell here and check the version:
The basic functionality of R on Nextjournal is similar to R in other contexts. Almost 100 extra packages are installed in the default environment, including the tidyverse, the devtools, feather, and plotly.
This code displays a sorted list of all packages that are installed in the 'R Default' environment:
Additional packages that are required for an article should be installed in the standard way using the install.packages() command, and saved to a new environment. If an existing article has the setup you need, you can transclude its environment into your article, or remix it.
Below, we demonstrate one method that you can use to create a plot from the 'iris' dataset using Plotly.
It is also possible to display many forms of data in the results area below a cell. Strings and simple variables will be printed, while more complicated structures (arrays, dictionaries) can appear as an expandable tree or a table.
There are multiple ways to get data in and out of Nextjournal. The most direct way to load our own data is to upload a file via the Insert Menu.
Files uploaded in this way are stored in a persistent, versioned database. We can access a file in a language cell by inserting a reference to it from the @-menu, which appears automatically when you type the '@' symbol.