Is there a way to collapse output produced in a Jupyter notebook? - jupyter-notebook

I am creating a Jupyter notebook to demo some functions that I have created and the outputs they produce. Is there a way to setup a Jupyter notebook such that any output produced after running a cell appears within an already collapsed cell? My motivation for this is that large output is printed by all of my functions, and I would prefer for the notebook to not become cluttered as I am demoing the functions.
Thank you in advance!

Related

Call notebook using R in Databricks

I have a R notebook in Databricks, that I want to call inside an other R notebook.
I know that to call the notebook_a, one should do :
%run /path/notebook_a
But I want to do it inside an R script. For example :
if(condition){ %run /path/notebook_a }
Of course this code does not work.
Thanks a lot.
You should be able to use dbutils.notebooks.run for calling another notebook, but there is a difference between it and %run:
dbutils.notebooks.run executes another notebook as a separate job, so no definitions, etc. is pulled into the context of the current notebook - you can communicated data via temp views, etc.
%run execute another notebook and pulls all definitions and sides effects into the context of the current notebook.
I'm not sure if dbutils.notebooks.run will help in your case.
P.S. I personally would recommend to use %run with notebooks that only define functions, not doing any calculations, etc. - in this case, even if you have %run this doesn't cause any side effect on your current context.

Change jupyter notebook theme to highlight R functions

I'm using the R programming language with jupyter notebook, but functions are not highlighted like for Python. Is there a way to modify the default theme?
Just to be clear, below I posted 2 images to show the difference between jupyter notebook and RStudio:
as you can see, functions like length, sort etc. are painted with their own color.

How to handle R kernel tibble in Jupyter lab .ipynb file to display limited row results?

I am trying using R Kernel in jupyter lab and getting 1000's of rows or more displaying when results are tibble, this makes my browser crash sometimes.
How do i limit these so that it doesn't make my browser crash and works as smoothly as in Rstudio ?
I am using below versions:
jupyter lab: Version 2.2.6
R: R version 4.0.3
Not exactly a proper solution but a way around that I tried is to pipe the results to print and mention number of rows there: validaton_splits %>% print(n=1).

Can a reveal.js slide deck compiled by jupyter nbconvert have two columns on one slide?

I'm writing a slide deck using the Jupyter notebook and compiling it to slides using jupyter nbconvert FILENAME.ipynb --to=slides, which uses Reveal.js (if I understand correctly). I'm consequently writing the slide content in Markdown.
I'd like to have a slide with two columns, if possible. I cannot seem to make this work. Here is what I have tried:
The splitcell notebook extension suggested here. This does not work because (I think) it's for RISE, and I'm using Reveal.js. By "does not work" I mean that the split cells are treated as if I had not split them; it seems to have no effect.
The CSS suggestions suggested in many responses to this question. While several of the answers to that question successfully let me create two columns, none lets me use Markdown inside the columns, even though several of them explicitly say that they do. I have tried obeying all the suggestions in the comments as well, including blank lines and data-markdown. Perhaps those solutions work correctly when compiling from Markdown to slides through Reveal.js, but something is different about jupyter nbconvert?
The contributed notebook extension Split Cells (repo on GitHub) does exactly this.
This blog post shows Split Cells in action.

R leaflet package inline in IPython Notebook

I'm using R in Ipython Notebook with R line and cell magics. All of my R plots print automatically inline except for the R package leaflet which opens in a new browser tab.
I've tried using %capture to capture the output. I've also tried doing different versions of --inline.
In knitr, the map is included inside the file following the code chunk. Any idea on how to get this functionality in ipython notebook using R?
Thanks in advance for any and all help.
Edit:
%%capture only works with strings.
You can display interactive maps inline using rMaps.
There is a demonstration notebook here:
http://nbviewer.ipython.org/github/ipython/front-to-back/blob/master/R_demo.ipynb

Resources