😃 R data package featuring every Lego set from 1970 to 2015
R Shell
Switch branches/tags
Nothing to show
Clone or download
seankross Merge pull request #2 from Ironholds/master
add package-level documentation
Latest commit e71d780 Sep 7, 2015
Permalink
Failed to load latest commit information.
R add package-level documentation Sep 7, 2015
data-raw added 2015 sets Sep 7, 2015
data-tidy added 2015 sets Sep 7, 2015
data added 2015 sets Sep 7, 2015
man add package-level documentation Sep 7, 2015
.Rbuildignore added raw data and code Oct 12, 2014
.gitignore added raw data and code Oct 12, 2014
DESCRIPTION added 2015 sets Sep 7, 2015
NAMESPACE first commit Aug 21, 2014
README.md added 2015 sets Sep 7, 2015
lego.Rproj first commit Aug 21, 2014

README.md

lego

This R data package contains information about every Lego set manufactured from 1970 to 2015, a total of 6172 sets. A few of the variables included for each set are:

  • Item number
  • Name
  • Year manufactured
  • Theme
  • Number of pieces
  • Number of minifigures included
  • Price

To install:

library(devtools)
install_github("seankross/lego")

Play well:

library(dplyr)

avg_price_per_year <- legosets %>%
  filter(!is.na(USD_MSRP)) %>%
  group_by(Year) %>%
  do(data.frame(Price = mean(.$USD_MSRP)))

med_price_per_year <- legosets %>%
  filter(!is.na(USD_MSRP)) %>%
  group_by(Year) %>%
  do(data.frame(Price = median(.$USD_MSRP)))

plot(avg_price_per_year, type = "l", col = "blue", 
     main = "Lego set prices over time", ylim = c(0, max(avg_price_per_year$Price)))
points(med_price_per_year, type = "l", col = "red")
legend("topleft", inset=c(0.2,0), legend=c("Average","Median"), lty=c(1,1), col=c("blue", "red"))