knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  cache = TRUE
)
library(kaggler)
options(width = 100)
options(tibble.print_min = 5)
options(tibble.print_max = 5)

kaggler

🏁 An R client for accessing Kaggle's API

Installation

You can install the dev version of {kaggler} from CRAN with:

## install kaggler package from github
devtools::install_packages("mkearney/kaggler")

API authorization

1. Go to https://www.kaggle.com/ and sign in

2. Click Account or navigate to https://www.kaggle.com/{username}/account

3. Scroll down to the API section and click Create New API Token (which should cause you to download a kaggle.json file with your username and API key)

4. There are a few different ways to store your credentials

kgl_auth(username = "mkearney", key = "9as87f6faf9a8sfd76a9fsd89asdf6dsa9f8")
#> Your Kaggle key has been recorded for this session and saved as `KAGGLE_PAT` environment variable for future sessions.

kgl_competitions_list_.*()

Browse or search for Kaggle compeitions.

## look through all competitions (paginated)
comps1 <- kgl_competitions_list()
comps1

## it's paginated, so to see page two:
comps2 <- kgl_competitions_list(page = 2)
comps2

## search by keyword for competitions
imagecomps <- kgl_competitions_list(search = "image")
imagecomps

kgl_competitions_data_.*()

Look up the datalist for a given Kaggle competition. IF you've already accepted the competition rules, then you should be able to download the dataset too (I haven't gotten there yet to test it)

## data list for a given competition
c1_datalist <- kgl_competitions_data_list(comps1$id[1])
c1_datalist

## download set sets (IF YOU HAVE ACCEPTED COMPETITION RULES)
c1_data <- kgl_competitions_data_download(
  comps1$id[1], c1_datalist$name[1])

kgl_datasets_.*()

Get a list of all of the datasets.

## get competitions data list
datasets <- kgl_datasets_list()
datasets

kgl_competitions_leaderboard_.*()

View the leaderboard for a given competition.

## get competitions data list
c1_leaderboard <- kgl_competitions_leaderboard_view(comps1$id[1])
c1_leaderboard

Note(s)



mkearney/kaggle documentation built on May 28, 2019, 4:32 a.m.