作者: Jason Bryer博士[email protected]
網站: https://jbryer.github.io/brickset/
該軟件包提供了從Brickset網站訪問有關樂高集合的數據的功能。該軟件包還包含一個數據。從1970年到2022年的所有樂高集合(n = 18,455)的data.frame 。此數據集是使用getSets函數創建的,建議您使用此數據框架來減少API調用的數量。有關如何創建數據框,請參見build.r腳本。有關變量的信息如下。
您可以從Cran下載:
install.packages( ' brickset ' )或使用remotes軟件包的最新開發版本:
remotes :: install_github( ' jbryer/brickset ' )要使用Brickset API,您必須首先創建一個Brickset帳戶並請求API密鑰。完整的Brickset API文檔可在此處找到:https://brickset.com/article/52664/api-version-3-documentation
大多數功能都需要一個磚頭用戶名,密碼和API鍵。您可以將其作為參數傳遞,也可以設置以下選項:
options( brickset_key = ' YOUR_API_KEY ' ,
brickset_username = ' YOUR_USERNAME ' ,
brickset_password = ' YOUR_PASSWORD ' ) checkKey函數將驗證您的API密鑰是否有效:
brickset :: checkKey()
# > [1] TRUE您可以使用getKeyUsageStats函數檢查API使用情況。
brickset :: getKeyUsageStats()
# > dateStamp count
# > 1 2023-03-30T00:00:00Z 3
# > 2 2023-03-24T00:00:00Z 2
# > 3 2023-03-23T00:00:00Z 2
# > 4 2023-03-22T00:00:00Z 16
# > 5 2023-03-21T00:00:00Z 2 getSets功能從給定年份返回所有樂高集合。
sets2021 <- brickset :: getSets( 2021 )
head( sets2021 , n = 3 )
# > setID name year theme themeGroup
# > 1 31026 Police Station 2021 Icons Model making
# > 2 31754 Volkswagen T2 Camper Van 2021 Icons Model making
# > 3 31025 Flower Bouquet 2021 Icons Model making
# > subtheme category released pieces minifigs
# > 1 Modular Buildings Collection Normal TRUE 2923 5
# > 2 Vehicles Normal TRUE 2207 NA
# > 3 Botanical Collection Normal TRUE 756 NA
# > bricksetURL rating reviewCount packagingType
# > 1 https://brickset.com/sets/10278-1 4.4 4 Box
# > 2 https://brickset.com/sets/10279-1 4.1 0 Box
# > 3 https://brickset.com/sets/10280-1 4.3 3 Box
# > availability agerange_min US_retailPrice US_dateFirstAvailable
# > 1 LEGO exclusive 18 199.99 2021-01-02T00:00:00Z
# > 2 LEGO exclusive 18 179.99 2021-08-02T00:00:00Z
# > 3 Retail 18 59.99 2021-01-02T00:00:00Z
# > US_dateLastAvailable UK_retailPrice UK_dateFirstAvailable
# > 1 <NA> 169.99 2021-01-01T00:00:00Z
# > 2 2022-11-12T00:00:00Z 139.99 2021-08-01T00:00:00Z
# > 3 <NA> 54.99 2021-01-01T00:00:00Z
# > UK_dateLastAvailable CA_retailPrice CA_dateFirstAvailable
# > 1 <NA> 269.99 2021-01-02T00:00:00Z
# > 2 2022-11-29T00:00:00Z 249.99 2021-08-03T00:00:00Z
# > 3 <NA> 79.99 2021-01-02T00:00:00Z
# > CA_dateLastAvailable DE_retailPrice DE_dateFirstAvailable
# > 1 <NA> 199.99 2021-01-02T00:00:00Z
# > 2 2022-11-12T00:00:00Z 159.99 2021-08-02T00:00:00Z
# > 3 <NA> 59.99 2021-01-02T00:00:00Z
# > DE_dateLastAvailable height width depth weight
# > 1 <NA> 47.6 57.7 11.8 4.012
# > 2 2022-11-30T00:00:00Z 37.4 57.8 11.2 2.945
# > 3 <NA> 38.2 26.2 7.1 0.760
# > thumbnailURL
# > 1 https://images.brickset.com/sets/small/10278-1.jpg
# > 2 https://images.brickset.com/sets/small/10279-1.jpg
# > 3 https://images.brickset.com/sets/small/10280-1.jpg
# > imageURL
# > 1 https://images.brickset.com/sets/images/10278-1.jpg
# > 2 https://images.brickset.com/sets/images/10279-1.jpg
# > 3 https://images.brickset.com/sets/images/10280-1.jpg getReviews功能將返回給定集的所有評論。
reviews29830 <- brickset :: getReviews( 29830 )
names( reviews29830 )
# > [1] "author" "datePosted" "title"
# > [4] "review" "HTML" "overall"
# > [7] "parts" "buildingExperience" "playability"
# > [10] "valueForMoney" getThemes和getSubthemes返回有關樂高主題的信息。
getThemes() | > head( n = 3 )
# > theme setCount subthemeCount yearFrom yearTo
# > 1 {Unknown IP} 5 0 2023 2023
# > 2 4 Juniors 24 5 2003 2004
# > 3 Action Wheelers 9 0 2000 2001
getSubthemes( ' Toy Story ' )
# > theme subtheme setCount yearFrom yearTo
# > 1 Toy Story Buildable Figures 2 2010 2010
# > 2 Toy Story Original Film 2 2010 2010
# > 3 Toy Story Toy Story 2 3 2010 2010
# > 4 Toy Story Toy Story 3 8 2010 2010
getYears( ' Toy Story ' )
# > theme year setCount
# > 1 Toy Story 2010 15 getInstructions將將帶有URL的表返回到建築物說明中。
instructions <- getInstructions( setID = 29830 )
instructions
# > URL
# > 1 https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6313846.pdf
# > 2 https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6313848.pdf
# > 3 https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6313849.pdf
# > 4 https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6313850.pdf
# > description
# > 1 BI 3103, 112+4/65+200G, 10270 V29 1/2
# > 2 BI 3103, 96+4/65+200G,10270 V29 2/2
# > 3 BI 3103, 112+4/65+200G, V39/142 1/2
# > 4 BI 3103, 96+4/65+200G, V39/142 2/2 legosets數據集從1970年到2022年, legosets數據框架包含所有樂高集合(n = 18,455)。
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 ' )
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) ' )
legosets數據框中的變量是:
| 類型 | unique_values | |
|---|---|---|
| setid | 整數 | 18455 |
| 姓名 | 特點 | 15372 |
| 年 | 整數 | 53 |
| 主題 | 特點 | 154 |
| themegroup | 特點 | 16 |
| 子圖 | 特點 | 901 |
| 類別 | 特點 | 7 |
| 發行 | 邏輯 | 2 |
| 件 | 整數 | 1403 |
| minifigs | 整數 | 34 |
| 磚頭 | 特點 | 18455 |
| 等級 | 數字 | 31 |
| 評論 | 整數 | 64 |
| 包裝類型 | 特點 | 18 |
| 可用性 | 特點 | 10 |
| Agerange_min | 整數 | 16 |
| US_RETAILPRICE | 數字 | 142 |
| US_DATEFIRSTAVAILABLE | 日期 | 881 |
| US_DATELASTAVAILABLE | 日期 | 2125 |
| uk_retailprice | 數字 | 210 |
| uk__datefirstavailable | 日期 | 825 |
| UK__DATELASTAVAILABLE | 日期 | 1984 |
| ca_retailprice | 數字 | 162 |
| ca_datefirstavailable | 日期 | 641 |
| ca_datelastavailable | 日期 | 1808年 |
| de_retailprice | 數字 | 155 |
| de_datefirstavailable | 日期 | 428 |
| de_datelastavailable | 日期 | 1176 |
| 高度 | 數字 | 241 |
| 寬度 | 數字 | 286 |
| 深度 | 數字 | 279 |
| 重量 | 數字 | 1046 |
| Thumbnailurl | 特點 | 17420 |
| ImageUrl | 特點 | 17420 |
請注意,Brickset Project已發布貢獻者的行為準則。通過為該項目做出貢獻,您同意遵守其條款。