{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction to Python (Part 1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## IPython kernel is polyglot" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/opt/conda/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\n" ] } ], "source": [ "%%bash\n", "\n", "echo $PATH" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "%load_ext rpy2.ipython" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ " [1] 1 2 3 4 5 6 7 8 9 10\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%%R\n", "\n", "1:10" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ " Sepal.Length Sepal.Width Petal.Length Petal.Width Species\n", "1 5.1 3.5 1.4 0.2 setosa\n", "2 4.9 3.0 1.4 0.2 setosa\n", "3 4.7 3.2 1.3 0.2 setosa\n", "4 4.6 3.1 1.5 0.2 setosa\n", "5 5.0 3.6 1.4 0.2 setosa\n", "6 5.4 3.9 1.7 0.4 setosa\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%%R -o iris\n", "\n", "head(iris)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Sepal.Length | \n", "Sepal.Width | \n", "Petal.Length | \n", "Petal.Width | \n", "Species | \n", "
---|---|---|---|---|---|
1 | \n", "5.1 | \n", "3.5 | \n", "1.4 | \n", "0.2 | \n", "setosa | \n", "
2 | \n", "4.9 | \n", "3.0 | \n", "1.4 | \n", "0.2 | \n", "setosa | \n", "
3 | \n", "4.7 | \n", "3.2 | \n", "1.3 | \n", "0.2 | \n", "setosa | \n", "
4 | \n", "4.6 | \n", "3.1 | \n", "1.5 | \n", "0.2 | \n", "setosa | \n", "
5 | \n", "5.0 | \n", "3.6 | \n", "1.4 | \n", "0.2 | \n", "setosa | \n", "