├── img └── README.md ├── datasets └── README.md ├── .gitignore ├── README.md ├── audition.ipynb └── create_tests.ipynb /img/README.md: -------------------------------------------------------------------------------- 1 | Store your images in this folder. 2 | -------------------------------------------------------------------------------- /datasets/README.md: -------------------------------------------------------------------------------- 1 | Store your data in this folder. 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS files to ignore 2 | .DS_Store 3 | 4 | # Python files ignore 5 | .ipynb_checkpoints 6 | .nbgrader.log 7 | .ipynb_checkpoints 8 | __pycache__ 9 | 10 | # R files to ignore 11 | .Rhistory 12 | .Rapp.history 13 | .RData 14 | .Rproj.user 15 | *.Rproj 16 | .httr-oauth 17 | /*_cache/ 18 | /cache/ 19 | *.utf8.md 20 | *.knit.md 21 | 22 | # misc to ignore 23 | project_template_todo.txt 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # projects-instructor-application-r 2 | The audition and tests portions of the application process for becoming a project instructor 3 | 4 | See this [Intercom article](https://instructor-support.datacamp.com/projects/the-application-process-for-becoming-a-project-instructor) for a full description. 5 | 6 | # Things to install 7 | 8 | There are some packages you need to be able to create DataCamp projects locally. Run the following commands in R to install them. 9 | 10 | ``` 11 | install.packages("devtools") 12 | install.packages("testthat") 13 | devtools::install_github('datacamp/IRkernel.testthat') 14 | ``` 15 | -------------------------------------------------------------------------------- /audition.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "Welcome to your DataCamp Project audition! This notebook must be filled out and vetted before a contract can be signed and you can start creating your Project.\n", 10 | "\n", 11 | "The first step is forking the repository in which this notebook lives. After that, there are three parts to be completed in this notebook:\n", 12 | "\n", 13 | "- **Project information**: The title of the Project, a Project description, etc.\n", 14 | "\n", 15 | "- **Project introduction**: The three first text and code cells that will form the introduction of your Project.\n", 16 | "\n", 17 | "- **Rough draft of code for rest of Project:** a rough draft of the remaining code for the rest of your Project (no accompanying text cells required).\n", 18 | "\n", 19 | "When complete, please email the link to your forked repo to projects@datacamp.com with the email subject line _DataCamp Project audition_. If you have any questions, please reach out to projects@datacamp.com." 20 | ] 21 | }, 22 | { 23 | "cell_type": "markdown", 24 | "metadata": {}, 25 | "source": [ 26 | "# Project information" 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "metadata": {}, 32 | "source": [ 33 | "**Project title**: The title of the Project. Maximum 41 characters.\n", 34 | "\n", 35 | "**Name:** Your full name.\n", 36 | "\n", 37 | "**Email address associated with your DataCamp account:** You can find this email [here](https://www.datacamp.com/profile/account_settings) if you have a DataCamp account.\n", 38 | "\n", 39 | "**Project description**: This will be read by the students on the DataCamp platform **before** deciding to start the Project. The description should be three paragraphs, written in Markdown.\n", 40 | "\n", 41 | "- Paragraph 1 should be an exciting introduction to analysis/model/etc. students will complete.\n", 42 | "- Paragraph 2 should list the background knowledge you assume the student doing this Project will have, the more specific the better. Please list things like modules, tools, functions, methods, statistical concepts, etc.\n", 43 | "- Paragraph 3 should describe and link to (if possible) the dataset used in the Project." 44 | ] 45 | }, 46 | { 47 | "cell_type": "markdown", 48 | "metadata": {}, 49 | "source": [ 50 | "# Project introduction\n", 51 | "\n", 52 | "***Note: nothing needs to be filled out in this cell. It is simply setting up the template cells below.***\n", 53 | "\n", 54 | "The final output of a DataCamp Project looks like a blog post: pairs of text and code cells that tell a story about data. The text is written from the perspective of the data analyst and *not* from the perspective of an instructor on DataCamp. So, for this blog post intro, all you need to do is pretend like you're writing a blog post -- forget the part about instructors and students.\n", 55 | "\n", 56 | "Below you'll see the structure of a DataCamp Project: a series of \"tasks\" where each task consists of a title, a **single** text cell, and a **single** code cell. There are 8-12 tasks in a Project and each task can have up to 10 lines of code. What you need to do:\n", 57 | "1. Read through the template structure.\n", 58 | "2. As best you can, divide your Project as it is currently visualized in your mind into tasks.\n", 59 | "3. Fill out the template structure for the first three tasks of your Project.\n", 60 | "\n", 61 | "As you are completing each task, you may wish to consult the Project notebook format in our [documentation](https://instructor-support.datacamp.com/projects/datacamp-projects-jupyter-notebook). Only the `@context` and `@solution` cells are relevant to this audition." 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "## 1. Title of the first task (<= 55 chars) (sentence case)" 69 | ] 70 | }, 71 | { 72 | "cell_type": "markdown", 73 | "metadata": {}, 74 | "source": [ 75 | "An exciting intro to the analysis. Provide context on the problem you're going to solve, the dataset(s) you're going to use, the relevant industry, etc. You may wish to briefly introduce the techniques you're going to use. Tell a story to get students excited! It should at most have 1200 characters.\n", 76 | "\n", 77 | "The most common error instructors make in **context cells** is referring to the student or the Project. We want Project notebooks to appear as a blog post or a data analysis. Bad: *\"In this Project, you will...\"* Good: *\"In this notebook, we will...\"*\n", 78 | "\n", 79 | "The first task in Projects often involve loading data. Please store any data files you use in the `datasets/` folder in this repository.\n", 80 | "\n", 81 | "Images are welcome additions to every Markdown cell, but especially this first one. Make sure the images you use have a [permissive license](https://support.google.com/websearch/answer/29508?hl=en) and display them using [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#images). Store your images in the `img/` folder in this repository." 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": null, 87 | "metadata": {}, 88 | "outputs": [], 89 | "source": [ 90 | "# Code and comments for the first task\n", 91 | "# It should consist of up to 10 lines of code (not including comments)\n", 92 | "# and take at most 10 seconds to execute on an average laptop." 93 | ] 94 | }, 95 | { 96 | "cell_type": "markdown", 97 | "metadata": {}, 98 | "source": [ 99 | "## 2. Title of the second task (<= 55 chars) (sentence case)" 100 | ] 101 | }, 102 | { 103 | "cell_type": "markdown", 104 | "metadata": {}, 105 | "source": [ 106 | "Context / background / story / etc. This cell should at most have 800 characters.\n", 107 | "\n", 108 | "The most common error instructors make in **context cells** is referring to the student or the Project. We want Project notebooks to appear as a blog post or a data analysis. Bad: *\"In this task, you will...\"* Good: *\"Next, we will...\"*" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": null, 114 | "metadata": {}, 115 | "outputs": [], 116 | "source": [ 117 | "# Code and comments for the second task\n", 118 | "# It should consist of up to 10 lines of code (not including comments)\n", 119 | "# and take at most 10 seconds to execute on an average laptop." 120 | ] 121 | }, 122 | { 123 | "cell_type": "markdown", 124 | "metadata": {}, 125 | "source": [ 126 | "## 3. Title of the third task (<= 55 chars) (sentence case)" 127 | ] 128 | }, 129 | { 130 | "cell_type": "markdown", 131 | "metadata": {}, 132 | "source": [ 133 | "Context / background / story / etc. This cell should at most have 800 characters.\n", 134 | "\n", 135 | "The most common error instructors make in **context cells** is referring to the student or the Project. We want Project notebooks to appear as a blog post or a data analysis. Bad: *\"In this task, you will...\"* Good: *\"Next, we will...\"*" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": null, 141 | "metadata": {}, 142 | "outputs": [], 143 | "source": [ 144 | "# Code and comments for the third task\n", 145 | "# It should consist of up to 10 lines of code (not including comments)\n", 146 | "# and take at most 10 seconds to execute on an average laptop." 147 | ] 148 | }, 149 | { 150 | "cell_type": "markdown", 151 | "metadata": {}, 152 | "source": [ 153 | "# Rough draft of code for rest of Project\n", 154 | "Please include a rough draft of the code for the rest of your proposed Project below. Use as many code cells as you'd like. No accompanying text (i.e. context) cells required." 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": null, 160 | "metadata": {}, 161 | "outputs": [], 162 | "source": [] 163 | } 164 | ], 165 | "metadata": { 166 | "kernelspec": { 167 | "display_name": "R", 168 | "language": "R", 169 | "name": "ir" 170 | }, 171 | "language_info": { 172 | "codemirror_mode": "r", 173 | "file_extension": ".r", 174 | "mimetype": "text/x-r-source", 175 | "name": "R", 176 | "pygments_lexer": "r", 177 | "version": "3.5.3" 178 | } 179 | }, 180 | "nbformat": 4, 181 | "nbformat_minor": 2 182 | } 183 | -------------------------------------------------------------------------------- /create_tests.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Create Tests\n", 8 | "\n", 9 | "The next step for creating a DataCamp project in R is creating a few tests using the [`testthat` package](https://github.com/r-lib/testthat), which is how instructors deliver feedback on the code students write in a project. The [testing chapter](http://r-pkgs.had.co.nz/tests.html) in Hadley Wickham's _R packages_ book gets into the details of testing with `testthat`, along with workflow advice and concrete examples.\n", 10 | "\n", 11 | "After installing the necessary libraries (described below), please create tests for the project tasks below, which were taken from a real live DataCamp project!\n", 12 | "\n", 13 | "When complete, please email the link to your forked repo to projects@datacamp.com with the email subject line _DataCamp project tests_. If you have any questions, please reach out to projects@datacamp.com." 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": null, 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# To be able to run tests locally in the notebook, install the following:\n", 23 | "# install.packages(\"devtools\")\n", 24 | "# install.packages(\"testthat\")\n", 25 | "# devtools::install_github(\"datacamp/IRkernel.testthat\")" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "## An example of a `testthat` test\n", 33 | "\n", 34 | "Instructions to the student in the project:\n", 35 | "\n", 36 | "- Load the `readr` and `dplyr` packages.\n", 37 | "- Load the dataset, `datasets/by_tag_year.csv`, into a variable named `by_tag_year` using the `read_csv()` function (**not** `read.csv()`).\n", 38 | "- Print `by_tag_year`.\n", 39 | "\n", 40 | "A potential **incorrect** submission is as follows. Please process the cell below. *Note: `by_tag_year.csv` exists in a directory named `datasets` in the same directory as this `create_tests.ipynb` notebook.*" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# Load packages\n", 50 | "library(readr)\n", 51 | "\n", 52 | "# Load dataset\n", 53 | "by_tag_year <- read.csv(\"datasets/by_tag_year.csv\")\n", 54 | "\n", 55 | "# Inspect the dataset\n", 56 | "print(by_tag_year)" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "Inspect the `testthat` test below, then run the test locally. (Processing the cell above followed by the cell below will run the test locally.)" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": null, 69 | "metadata": {}, 70 | "outputs": [], 71 | "source": [ 72 | "# These packages need to be loaded in the first `@tests` cell. \n", 73 | "library(testthat) \n", 74 | "library(IRkernel.testthat)\n", 75 | "\n", 76 | "# The purpose of tests are to try to catch common errors and to \n", 77 | "# give the student a hint on how to resolve these errors.\n", 78 | "# The solution should pass the tests.\n", 79 | "run_tests({\n", 80 | " test_that(\"packages are loaded\", {\n", 81 | " expect_true(\"readr\" %in% .packages(), info = \"Did you load the readr package?\")\n", 82 | " expect_true(\"dplyr\" %in% .packages(), info = \"Did you load the dplyr package?\")\n", 83 | " })\n", 84 | " \n", 85 | " test_that(\"by_tag_year is correct\", {\n", 86 | " expect_is(by_tag_year, \"tbl_df\", \n", 87 | " info = \"Did you read in by_tag_year with read_csv (not read.csv)?\")\n", 88 | " expect_equal(nrow(by_tag_year), 40518, \n", 89 | " info = \"Did you read in by_tag_year with read_csv?\")\n", 90 | " })\n", 91 | "})" 92 | ] 93 | }, 94 | { 95 | "cell_type": "markdown", 96 | "metadata": {}, 97 | "source": [ 98 | "A potential **correct** submission is as follows. Please process the cell below to overwrite the previous incorrect solution." 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": null, 104 | "metadata": {}, 105 | "outputs": [], 106 | "source": [ 107 | "# Load package\n", 108 | "library(readr)\n", 109 | "library(dplyr)\n", 110 | "\n", 111 | "# Load dataset\n", 112 | "by_tag_year <- read_csv(\"datasets/by_tag_year.csv\")\n", 113 | "\n", 114 | "# Inspect the dataset\n", 115 | "print(by_tag_year)" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": null, 121 | "metadata": {}, 122 | "outputs": [], 123 | "source": [ 124 | "run_tests({\n", 125 | " test_that(\"packages are loaded\", {\n", 126 | " expect_true(\"readr\" %in% .packages(), info = \"Did you load the readr package?\")\n", 127 | " expect_true(\"dplyr\" %in% .packages(), info = \"Did you load the dplyr package?\")\n", 128 | " })\n", 129 | " \n", 130 | " test_that(\"by_tag_year is correct\", {\n", 131 | " expect_is(by_tag_year, \"tbl_df\", \n", 132 | " info = \"Did you read in by_tag_year with read_csv (not read.csv)?\")\n", 133 | " expect_equal(nrow(by_tag_year), 40518, \n", 134 | " info = \"Did you read in by_tag_year with read_csv?\")\n", 135 | " })\n", 136 | "})" 137 | ] 138 | }, 139 | { 140 | "cell_type": "markdown", 141 | "metadata": {}, 142 | "source": [ 143 | "## Create a test\n", 144 | "It's your turn to create a test now!\n", 145 | "\n", 146 | "Instructions to the student in the project:\n", 147 | "* Use `mutate()` to add a column called `fraction` to `by_tag_year`, representing `number` divided by `year_total`. Name the new table `by_tag_year_fraction`.\n", 148 | "* Print `by_tag_year_fraction`.\n", 149 | "\n", 150 | "A potential **incorrect** submission is as follows. Please process the cell below." 151 | ] 152 | }, 153 | { 154 | "cell_type": "code", 155 | "execution_count": null, 156 | "metadata": {}, 157 | "outputs": [], 158 | "source": [ 159 | "# Add fraction column\n", 160 | "by_tag_year_fraction <- by_tag_year %>%\n", 161 | " mutate(fraction = num / year_total)\n", 162 | "\n", 163 | "# Print the new table\n", 164 | "print(by_tag_year_fraction)" 165 | ] 166 | }, 167 | { 168 | "cell_type": "markdown", 169 | "metadata": {}, 170 | "source": [ 171 | "Please fill in the following `testthat` test template to test if:\n", 172 | "- `by_tag_year_fraction` is of class `tbl_df`\n", 173 | "- a new column named \"fraction\" was created (hint: use `colnames()` with the `%in%` operator)\n", 174 | "- the contents of the \"fraction\" column are correct\n", 175 | "\n", 176 | "Include a helpful feedback message for failing submissions. The test should fail since the above solution is incorrect." 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": null, 182 | "metadata": {}, 183 | "outputs": [], 184 | "source": [ 185 | "run_tests({\n", 186 | " # .... YOUR TEST(S) HERE ....\n", 187 | "})" 188 | ] 189 | }, 190 | { 191 | "cell_type": "markdown", 192 | "metadata": {}, 193 | "source": [ 194 | "A potential **correct** solution is as follows. Please process the cell below." 195 | ] 196 | }, 197 | { 198 | "cell_type": "code", 199 | "execution_count": null, 200 | "metadata": {}, 201 | "outputs": [], 202 | "source": [ 203 | "# Add fraction column\n", 204 | "by_tag_year_fraction <- by_tag_year %>%\n", 205 | " mutate(fraction = number / year_total)\n", 206 | "\n", 207 | "# Print the new table\n", 208 | "print(by_tag_year_fraction)" 209 | ] 210 | }, 211 | { 212 | "cell_type": "markdown", 213 | "metadata": {}, 214 | "source": [ 215 | "Please copy and paste the test you just wrote into the cell below and process it. The test should pass." 216 | ] 217 | }, 218 | { 219 | "cell_type": "code", 220 | "execution_count": null, 221 | "metadata": {}, 222 | "outputs": [], 223 | "source": [ 224 | "# copy and paste your test here, then process this cell" 225 | ] 226 | } 227 | ], 228 | "metadata": { 229 | "kernelspec": { 230 | "display_name": "R", 231 | "language": "R", 232 | "name": "ir" 233 | }, 234 | "language_info": { 235 | "codemirror_mode": "r", 236 | "file_extension": ".r", 237 | "mimetype": "text/x-r-source", 238 | "name": "R", 239 | "pygments_lexer": "r", 240 | "version": "3.5.0" 241 | } 242 | }, 243 | "nbformat": 4, 244 | "nbformat_minor": 2 245 | } 246 | --------------------------------------------------------------------------------