An open API service indexing awesome lists of open source software.

https://github.com/koderkow/aocr

An R client for accessing Advent of Code’s data
https://github.com/koderkow/aocr

r rstats

Last synced: about 2 months ago
JSON representation

An R client for accessing Advent of Code’s data

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
cache = TRUE
)
```

# aocr

> 💻 An R client for accessing [Advent of Code](https://adventofcode.com/)'s data

- This package will only help obtain data, it will not assist in posting solutions via HTTP request
- All requests are cached to reduce the number of interactions with Advent of Code's website

[![R-CMD-check](https://github.com/KoderKow/aocr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/KoderKow/aocr/actions/workflows/R-CMD-check.yaml)

## Installation

You can install the dev version of **{aocr}** from [GitHub](https://github.com/koderkow/aocr) with:

```{r, eval = FALSE}
devtools::install_packages("koderkow/aocr")
```

# Load the package

```{r pkg load}
library(aocr)
```

# Session ID

A session ID is needed to get a proper response from the Advent of Code's website. To obtain and set this as an environment variable run `aoc_set_session_id()`.

# Obtaining data

## Tibble

There are currently two function for obtaining data for the Advent of Code challenges:

```{r read data as tibble}
d_init <- aoc_get_data_as_tibble(2022, 1)

head(d_init)
```

## Raw response

If `aoc_get_data_as_tibble()` doesn't get the data in the right format, working with the response will be needed. [{httr2}](https://httr2.r-lib.org/) is the engine for making HTTP requests. Familiarity with that package will be needed to clean/parse the response.

```{r read data as resp}
resp <- aoc_get_response(2022, 1)

resp
```

# View the puzzle

If you need to view the puzzle's information to review or submit a solution it can be quickly pulled up via web browser:

```{r view puzzle, eval=FALSE}
aoc_view_puzzle(2022, 1)
```