Introduction to Jupyter

History and Status

Jupyter and the future of IPython https://ipython.org/ https://en.wikipedia.org/wiki/IPython

Installation

Basically, Download Continuum Anaconda http://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/install.html

Once you have conda, you may install “R Essentials” into the current environment:

conda install -c r r-essentials

Notebook

Here are some common usage:

  1. keyboard shortcut: https://sowingseasons.com/blog/reference/2016/01/jupyter-keyboard-shortcuts/23298516

  2. Inspect data files:

    !head -n 5 filename.ext
    
  3. load, save, run file

    %load file.py
    %%writefile myfile.py
    %run myfile.py
    
  4. time the execution:

    %timeit range(1000)
    %%timeit x = range(10000)
    ...: max(x)
    ...:
    
  5. for more magic and help:

    %lsmagic
    %COMMAND-NAME?
    
  6. display html:

    from IPython.core.display import display, HTML
    display(HTML('<h1>Hello, world!</h1>'))
    
  7. display image:

    from IPython.display import Image, display
    display(Image(filename='test.png'))
    
  8. display video:

    from IPython.display import YouTubeVideo
    YouTubeVideo('sjfsUzECqK0')
    
  9. create javascript:

    from IPython.display import Javascript
    Javascript("""
    $.getScript('http://d3js.org/d3.v3.min.js')
    """)