- Difficulty level: easy
- Time need to lean: 10 minutes or less
You can include headers, lists, figures, tables in your Jupyter notebook using markdown cells. These markdown cells are rendered by Jupyter itself and do not interact with the kernels. Consequently, it is not possible to pass information (e.g. results from analysis) to markdown cells to generate dynamic output. In contrast, RStudio/RMarkdown has long allowed the inclusion of expressions in markdown texts.
To overcome this problem, you can install a markdown kernel with commands
pip install markdown-kernel
python -m markdown.kernel install
and write markdown code in code cells with a markdown kernel.
The significance of the markdown kernel is that you can pass information from SoS to it through the %expand
magic. For example, suppose you have defined a function to calculate Fibonacci sequence,
You can write use it in Python expressions as follows:
The --in
option of magic %expand
allows you to expand the cell content in specific subkernel, if its language module supports the expand protocol. This allows the content in markdown cells to be expanded in other languages such as R.
For example,
If you have a block of text from RStudio in RMarkdown format, you can specify the Rmarkdown-style delimiters to evaluate the RMarkdown text directly.