{ "cells": [ { "cell_type": "markdown", "metadata": { "papermill": { "duration": 0.010609, "end_time": "2019-11-12T16:24:25.690499", "exception": false, "start_time": "2019-11-12T16:24:25.679890", "status": "completed" }, "tags": [] }, "source": [ "## Introduction to ggplot2" ] }, { "cell_type": "markdown", "metadata": { "papermill": { "duration": 0.008946, "end_time": "2019-11-12T16:24:25.708931", "exception": false, "start_time": "2019-11-12T16:24:25.699985", "status": "completed" }, "tags": [] }, "source": [ "This is a short demo on how to convert an R Markdown Notebook into an IPython Notebook using knitr and notedown.\n", "\n", "Adding a Python Chunk" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "kernel": "Python3", "papermill": { "duration": 1.628914, "end_time": "2019-11-12T16:24:27.346978", "exception": false, "start_time": "2019-11-12T16:24:25.718064", "status": "completed" }, "tags": [ "report_cell" ] }, "outputs": [ { "data": { "text/plain": [ "4" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def f(x):\n", " return x + 2\n", "f(2)" ] }, { "cell_type": "markdown", "metadata": { "papermill": { "duration": 0.009428, "end_time": "2019-11-12T16:24:27.366175", "exception": false, "start_time": "2019-11-12T16:24:27.356747", "status": "completed" }, "tags": [] }, "source": [ "This is an introduction to [ggplot2](http://github.com/hadley/ggplot2). You can view the source as an R Markdown document, if you are using an IDE like RStudio, or as an IPython notebook, thanks to [notedown](https://github.com/aaren/notedown).\n", "\n", "We need to first make sure that we have `ggplot2` and its dependencies installed, using the `install.packages` function.\n", "\n", "Now that we have it installed, we can get started by loading it into our workspace" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "kernel": "R", "papermill": { "duration": 1.604241, "end_time": "2019-11-12T16:24:28.979967", "exception": false, "start_time": "2019-11-12T16:24:27.375726", "status": "completed" }, "tags": [ "report_cell" ] }, "outputs": [], "source": [ "library(ggplot2)" ] }, { "cell_type": "markdown", "metadata": { "papermill": { "duration": 0.009229, "end_time": "2019-11-12T16:24:28.998723", "exception": false, "start_time": "2019-11-12T16:24:28.989494", "status": "completed" }, "tags": [] }, "source": [ "We are now fully set to try and create some amazing plots." ] }, { "cell_type": "markdown", "metadata": { "papermill": { "duration": 0.009268, "end_time": "2019-11-12T16:24:29.017602", "exception": false, "start_time": "2019-11-12T16:24:29.008334", "status": "completed" }, "tags": [] }, "source": [ "#### Data\n", "\n", "We will use the ubiqutous [iris](http://stat.ethz.ch/R-manual/R-patched/library/datasets/html/iris.html) dataset." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "kernel": "R", "papermill": { "duration": 0.13188, "end_time": "2019-11-12T16:24:29.159109", "exception": false, "start_time": "2019-11-12T16:24:29.027229", "status": "completed" }, "tags": [ "report_cell" ] }, "outputs": [ { "data": { "text/html": [ "
Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
---|---|---|---|---|
<dbl> | <dbl> | <dbl> | <dbl> | <fct> |
5.1 | 3.5 | 1.4 | 0.2 | setosa |
4.9 | 3.0 | 1.4 | 0.2 | setosa |
4.7 | 3.2 | 1.3 | 0.2 | setosa |
4.6 | 3.1 | 1.5 | 0.2 | setosa |
5.0 | 3.6 | 1.4 | 0.2 | setosa |
5.4 | 3.9 | 1.7 | 0.4 | setosa |