Learn R Programming

bggAnalytics

R package for simple downloading and organisation of board game data using BoardGameGeek's XML API2. Users of R programming language should have no problems extracting their BGG games collection data, or in fact, the information about any games from BGG. This allows for automatisation of the collection exporting task, which has to be done manually on the BGG website.

Installation

The package will be uploaded to CRAN in the future. In the meanwhile, it can be installed using the devtools package.

library(devtools)
install_github("JakubBujnowicz/bggAnalytics")

How To Use?

The package uses R6 classes and data.table package as a backbone for data. Hence usage is heavily leaning on reference, which is quite uncommon for R programming language.

Easiest way to start is to create a bggCollection object for a certain user. For showcase purposes, I'm using my BGG account called Beo_.

library(bggAnalytics)
my_collection <- bggCollection$new(username = "Beo_")
my_collection

Another step would be to fetch some data - everything (from the set of currently supported variables) can be fetched using fetch method.

my_collection$fetch()
# Or
my_collection$fetch(c("name", "yearpublished"))

Method called extend can be used in the same manner to extend object's data slot by given variables.

my_collection$data
# Currently only objectid
my_collection$extend(c("name", "yearpublished"))
my_collection$data

Note that this extension is done by reference, hence no assignment is necessary.

One doesn't have to rely on a given user's collection to download game's data. You can find a game ID by looking at it's BGG hyperlink, e.g. https://boardgamegeek.com/boardgame/167791/terraforming-mars is a link for Terraforming Mars, hence 167791 is it's ID.

games <- bggGames$new(ids = 167791)
games$extend()
games$data

Naturally, multiple IDs may be supplied to bggGames object. One can always extract IDs from a collection by my_collection$ids.

Copy Link

Version

Install

install.packages('bggAnalytics')

Monthly Downloads

73

Version

0.2.1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Jakub Bujnowicz

Last Published

August 31st, 2022

Functions in bggAnalytics (0.2.1)

custom_fetches

Custom fetching methods for non-scalar variables
.bgg_url

Return a given BoardGameGeek URL
.private_getter

Getter for private slots of R6 objects
.bgg_readurl

Safely scrap HTML website
.process_params

Class parameters preprocessing
.compress

Compress vector into single string
.get_varspecs

Get variable specification table for a given class
.internal_fun

Get one of the internal functions from the package
.extend_url_by_params

Extend given URL by class params
.xml_concatenate

Concatenate XML nodesets from a list
.plural

Add '-s' to the end of a string based on a count
.split_acc2list

Split according to a list
.xml_expand

Get all 'items' nodes from XML Nodeset
extraction_functions

Extraction functions
h_index

H-Index
squeeze

Squeeze integers into a single string
bggAPI

Interface for BoardGameGeek's XML API2
bggAnalytics-package

bggAnalytics: BoardGameGeek's Board Game Data Analysis Tools
bgg_namestyle

Detect the namestyle of the data table
bgg_merge

Merge data from two bggAPI objects
bgg_topgames

Get IDs of top rated games on BoardGameGeek
bgg_gameurl

Get BoardGameGeek URLs for games with given IDs
bggGames

API for Games and Things
bggSearch

API for BoardGameGeek search engine
bggCollection

API for user collections
bgg_variables

All variables that are available for fetching through bggAPI objects