bggAPI {bggAnalytics} | R Documentation |
Interface for BoardGameGeek's XML API2
Description
This is a class that works as a main interface to
BoardGameGeek's API. All other bgg*
classes inherit from
bggAPI
. Furthermore, there is no initialization method for
bggAPI
as it serves just as a super class for other classes.
Active bindings
ids
Numeric vector of positive integers. Contains IDs of all BoardGameGeek items that were requested and are present in
data
. The vector is sorted by default.data
Data.table with currently fetched variables from the object's XML. It has a row count equal to the length of
ids
. Note that the copy is returned, so no modification ofdata
is possible outside of class methods.xml
An XML nodeset obtained through the BoardGameGeek's API. It's length is equal to the length of
ids
.api_url
A character vector of one or more strings with URLs used to fetch XMLs.
params
A list with object parameters.
timestamp
The date (with time) of the object creation and, what follows, the last moment that the data was certainly up to date.
Methods
Public methods
Method fetch()
Fetches variables with given variable_names
from the
object's xml
. Returns them as a list. This is a main method of
getting non-scalar variables (as they are hard to fit into a
data.table).
Usage
bggAPI$fetch(variable_names = NULL, compress = FALSE)
Arguments
variable_names
a character vector with names of variables to fetch.
compress
a logical value, decides whether the fetched variables should be compress into a scalar form (if possible).
Method expand()
Expands the data
table by given variable_names
by reference. For the list of available variables for every object
check the bgg_variables
dataset.
Usage
bggAPI$expand(variable_names = NULL)
Arguments
variable_names
a character vector with names of variables to add to
data
.
Method switch_namestyle()
Switches between two styles of naming the variables:
'classic'
and 'pretty'
. The former is a default value and
uses code names concordant with BoardGameGeek's naming convention in
the XMLs. The latter is more intuitive and uses UpperCamelCase.
Usage
bggAPI$switch_namestyle(to)
Arguments
to
a single string, either
'classic'
or'pretty'
.
Returns
Returns TRUE
or FALSE
invisibly depending on
whether the names have been switched.
Method clone()
The objects of this class are cloneable with this method.
Usage
bggAPI$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.