-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
78 lines (50 loc) · 1.98 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
cache = TRUE
)
```
# aocr
<!-- <img src="man/figures/logo.png" width="160px" align="right" /> -->
> 💻 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
<!-- badges: start -->
[![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)
<!-- badges: end -->
## 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)
```