{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "1bba73c1-9283-e3ee-ee2c-9da87cd961a0"
      },
      "outputs": [],
      "source": [
        "# This R environment comes with all of CRAN preinstalled, as well as many other helpful packages\n",
        "# The environment is defined by the kaggle/rstats docker image: https://github.com/kaggle/docker-rstats\n",
        "# For example, here's several helpful packages to load in \n",
        "\n",
        "library(ggplot2) # Data visualization\n",
        "library(readr) # CSV file I/O, e.g. the read_csv function\n",
        "\n",
        "# Input data files are available in the \"../input/\" directory.\n",
        "# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n",
        "\n",
        "system(\"ls ../input\")\n",
        "\n",
        "# Any results you write to the current directory are saved as output.\n",
        "packages <- c(\"jsonlite\", \"dplyr\", \"purrr\", \"tidytext\")\n",
        "purrr::walk(packages, library, character.only = TRUE, warn.conflicts = FALSE)\n",
        "\n",
        "data <- fromJSON(\"../input/train.json\")\n",
        "\n",
        "vars <- setdiff(names(data), c(\"features\", \"photos\"))\n",
        "data <- map_at(data, vars, unlist) %>% \n",
        "  tibble::as_tibble(.) %>%\n",
        "  select(listing_id, features, interest_level) %>%\n",
        "  mutate(interest_level = factor(interest_level, c(\"low\", \"medium\", \"high\")))\n",
        "\n",
        "head(data, n = 5)"
      ]
    }
  ],
  "metadata": {
    "_change_revision": 0,
    "_is_fork": false,
    "kernelspec": {
      "display_name": "R",
      "language": "R",
      "name": "ir"
    },
    "language_info": {
      "codemirror_mode": "r",
      "file_extension": ".r",
      "mimetype": "text/x-r-source",
      "name": "R",
      "pygments_lexer": "r",
      "version": "3.3.3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}