Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jbryer/brickset
R package to interface with the Brickset API for getting data about LEGO.
https://github.com/jbryer/brickset
lego rstats-package
Last synced: about 2 months ago
JSON representation
R package to interface with the Brickset API for getting data about LEGO.
- Host: GitHub
- URL: https://github.com/jbryer/brickset
- Owner: jbryer
- License: gpl-3.0
- Created: 2021-02-08T21:00:46.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-01-11T12:20:08.000Z (12 months ago)
- Last Synced: 2024-10-24T03:35:33.199Z (2 months ago)
- Topics: lego, rstats-package
- Language: R
- Homepage: https://jbryer.github.io/brickset/
- Size: 91.3 MB
- Stars: 13
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
output: github_document
md_extensions:
self_contained: true
editor_options:
chunk_output_type: console
---# brickset: An R Package to Interface with the Brickset API for Getting Data About LEGO sets
[![R-CMD-check](https://github.com/jbryer/brickset/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jbryer/brickset/actions/workflows/R-CMD-check.yaml)
`r badger::badge_devel("jbryer/brickset", "blue")`
`r badger::badge_cran_release("brickset")`
[![CRAN Status](https://badges.cranchecks.info/flavor/release/brickset.svg)](https://cran.r-project.org/web/checks/check_results_brickset.html)**Author:** Jason Bryer, Ph.D. [email protected]
**Website:** https://jbryer.github.io/brickset/```{r, echo=FALSE, results='hide', message=FALSE, warning=FALSE, error=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)library(brickset)
library(ggplot2)
library(knitr)
data("legosets", package = 'brickset')
source('brickset_config.R')
```This package provides functions to access data about [LEGO](https://www.lego.com/) sets from the [Brickset](https://brickset.com/) website. The package also contains a `data.frame` with all LEGO sets (n = `r prettyNum(nrow(legosets), big.mark = ',')`) from `r min(legosets$year)` through `r max(legosets$year)`. This data set was created using the `getSets` function and it is recommended that you use this data frame to reduce the number of API calls. See the [build.R](https://github.com/jbryer/PSAboot/blob/master/build.R) script for how the data frame was created. Information about the variables is included below.
## Installation
You can download from CRAN using:
```{r, eval=FALSE}
install.packages('brickset')
```Or the latest development version using the `remotes` package:
```{r, eval=FALSE}
remotes::install_github('jbryer/brickset')
```## Brickset API
To use the Brickset API, you must first create a [Brickset account](https://brickset.com/signup) and request an [API key](https://brickset.com/tools/webservices/requestkey). The full Brickset API documentation is available here: https://brickset.com/article/52664/api-version-3-documentation
Most of the functions require a Brickset username, password, and API key. You can pass these as parameters, or you can set these options:
```{r, eval=FALSE}
options(brickset_key = 'YOUR_API_KEY',
brickset_username = 'YOUR_USERNAME',
brickset_password = 'YOUR_PASSWORD')
```The `checkKey` function will verify that your API key is valid:
```{r}
brickset::checkKey()
```You can check your API usage with the `getKeyUsageStats` function.
```{r}
brickset::getKeyUsageStats()
```The `getSets` function returns all LEGO sets from the given year.
```{r}
sets2021 <- brickset::getSets(2021)
head(sets2021, n = 3)
```The `getReviews` function will return all reviews for a given set.
```{r}
reviews29830 <- brickset::getReviews(29830)
names(reviews29830)
```The `getThemes` and `getSubthemes` returns information about LEGO themes.
```{r}
getThemes() |> head(n = 3)
getSubthemes('Toy Story')
getYears('Toy Story')
```The `getInstructions` will return a table with the URLs to the building instructions.
```{r}
instructions <- getInstructions(setID = 29830)
instructions
```## `legosets` Dataset
The `legosets` data frame contains all LEGO sets (n = `r prettyNum(nrow(legosets), big.mark = ',')`) from `r min(legosets$year)` through `r max(legosets$year)`.
```{r legosets_by_year, fig.height=4}
data("legosets", package = "brickset")
ggplot(legosets, aes(x = year)) + geom_bar() +
ggtitle('Number of LEGO sets by year') +
xlab('Year') + ylab('Number of LEGO Sets')
``````{r pieces_by_price, fig.height=4, warning = FALSE}
ggplot(legosets, aes(x = pieces, y = US_retailPrice)) +
geom_point() +
ggtitle('Cost of LEGO sets by number of pieces') +
xlab('Number of LEGO pieces') + ylab('US Retail Price (dollars)')
```The variables in the `legosets` data frame are:
```{r, echo=FALSE, results='asis'}
legosets_cols <- data.frame(
row.names = names(legosets),
Type = character(ncol(legosets)),
Unique_Values = integer(ncol(legosets))
)for(i in names(legosets)) {
legosets_cols[i,'Type'] <- class(legosets[,i])
legosets_cols[i,'Unique_Values'] <- length(unique(legosets[,i]))
}
knitr::kable(legosets_cols, format = 'markdown')
```## Code of Conduct
Please note that the brickset project is released with a [Contributor Code of Conduct](https://jbryer.github.io/brickset/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.