-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
72 lines (47 loc) · 1.8 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
---
output: rmarkdown::github_document
---
# pigeon
Parse Portable Game Notation ('PGN') Files
## Description
'Portable Game Notation' ('PGN') is a plain text computer-processible format for recording chess games (both the moves and related data), supported by many chess programs. It was was devised around 1993, by Steven J. Edwards, and was first popularized via the 'Usenet' newsgroup 'rec.games.chess'. 'PGN' is structured "for easy reading and writing by human users and for easy parsing and generation by computer programs." The chess moves themselves are given in algebraic chess notation. Tools are provided to parse 'PGN' files into a data frame.
## What's in the tin?
The following functions are implemented:
- `pgn2sql`: Convert a PGN file to a SQLite DB
- `pgn_count`: Count number of games in a PGN file
- `pgn_parse_moves`: Parse a character vector of chess moves in algebraic notations
- `read_pgn`: Read in a PGN file
The following built-in data sets are included:
- `system.file("extdata", "r7.pgn", package="pigeon")`: 2017 FIDE World Cup extract
## Installation
```{r eval=FALSE}
devtools::install_github("hrbrmstr/pigeon")
```
```{r message=FALSE, warning=FALSE, error=FALSE, include=FALSE}
options(width=120)
```
## Usage
```{r message=FALSE, warning=FALSE, error=FALSE}
library(pigeon)
library(tidyverse)
# current verison
packageVersion("pigeon")
```
Built-in example
```{r message=FALSE, warning=FALSE, error=FALSE}
fide <- read_pgn(system.file("extdata", "r7.pgn", package="pigeon"))
fide
glimpse(fide)
```
Bigger example
```{r message=FALSE, warning=FALSE, error=FALSE}
tf <- tempfile(fileext = ".zip")
td <- tempdir()
download.file("https://www.pgnmentor.com/players/Adams.zip", tf)
fil <- unzip(tf, exdir = td)
adams <- read_pgn(fil)
adams
glimpse(adams)
unlink(tf)
unlink(fil)
```