Skip to content

Instantly share code, notes, and snippets.

@stedy
Created August 30, 2014 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stedy/92b949ba44effd66c855 to your computer and use it in GitHub Desktop.
Save stedy/92b949ba44effd66c855 to your computer and use it in GitHub Desktop.
Analysis of LEGO prices in 2014 & 1989
id pieces price collection
75059 3296 299.99 Star Wars
10221 3152 399.99 Star Wars
75037 178 14.99 Star Wars
75035 99 12.99 Star Wars
10188 3803 399.99 Star Wars
75036 83 12.99 Star Wars
75034 100 12.99 Star Wars
10240 1559 199.99 Star Wars
10225 2127 179.99 Star Wars
10236 1990 249.99 Star Wars
75021 1175 119.99 Star Wars
75044 262 29.99 Star Wars
75045 434 39.99 Star Wars
75046 481 49.99 Star Wars
75043 717 59.99 Star Wars
75042 439 49.99 Star Wars
70162 313 29.99 Ultra Agents
70163 429 39.99 Ultra Agents
70164 589 69.99 Ultra Agents
70165 1060 99.99 Ultra Agents
70161 241 19.99 Ultra Agents
70160 88 11.99 Ultra Agents
42000 1141 129.99 Technic
42021 186 19.99 Technic
42009 2606 219.99 Technic
42026 137 19.99 Technic
42027 148 19.99 Technic
70130 292 24.99 Chima
70131 257 29.99 Chima
70132 434 39.99 Chima
70134 684 59.99 Chima
70133 407 39.99 Chima
6177 650 29.99 Basics
5004192 1855 139.96 Minecraft
70728 1223 119.99 Ninjago
70727 426 39.99 Ninjago
70723 334 29.99 Ninjago
70726 253 34.99 Ninjago
70724 516 59.99 Ninjago
70725 691 89.99 Ninjago
70721 79 11.99 Ninjago
70721 196 19.99 Ninjago
70722 207 19.99 Ninjago
31313 601 349.99 Mindstorms
70814 709 59.99 LEGO Movie
70802 314 29.99 LEGO Movie
70802 314 29.99 LEGO Movie
70801 122 12.99 LEGO Movie
70803 197 19.99 LEGO Movie
70808 514 49.99 LEGO Movie
70815 854 79.99 LEGO Movie
70816 940 99.99 LEGO Movie
70807 412 34.99 LEGO Movie
70805 389 29.99 LEGO Movie
70809 738 69.99 LEGO Movie
70810 2742 249.99 LEGO Movie
10244 1746 149.99 Exclusive
10243 2469 159.99 Creator
10224 2766 199.99 Creator
10234 2989 319.99 Creator
10232 2194 149.99 Creator
10218 2032 149.99 Creator
10220 1334 119.99 Creator
71066 2523 199.99 Simpsons
41509 61 4.99 Mixels
41510 51 4.99 Mixels
41511 46 4.99 Mixels
41512 68 4.99 Mixels
41513 57 4.99 Mixels
41514 61 4.99 Mixels
41515 70 4.99 Mixels
41516 69 4.99 Mixels
41517 68 4.99 Mixels
10672 150 29.99 Juniors
10674 306 29.99 Juniors
10667 160 14.99 Juniors
10676 480 49.99 Juniors
10669 107 19.99 Juniors
10671 123 19.99 Juniors
60050 423 64.99 City
60051 610 149.99 City
60052 888 199.99 City
7499 24 19.99 City
7895 8 15.99 City
60035 374 49.99 City
60034 262 39.99 City
60036 735 89.99 City
60033 113 14.99 City
60032 44 6.99 City
60048 249 29.99 City
60042 110 19.99 City
60044 375 44.99 City
60047 854 99.99 City
60041 38 6.99 City
850617 34 14.99 City
76022 336 49.99 Marvel Superheroes
76015 237 19.99 Marvel Superheroes
76021 665 74.99 Marvel Superheroes
76020 434 39.99 Marvel Superheroes
76019 196 19.99 Marvel Superheroes
76013 486 49.99 DC Superheroes
76011 184 19.99 DC Superheroes
10937 1619 159.99 DC Superheroes
31015 56 4.99 Creator
31014 64 4.99 Creator
31013 66 4.99 Creator
31023 328 29.99 Creator
31024 374 29.99 Creator
31026 1023 89.99 Creator
31025 550 39.99 Creator
41054 299 39.99 Disney Princess
41053 274 29.99 Disney Princess
41050 77 12.99 Disney Princess
41026 233 19.99 Friends
41057 355 39.99 Friends
41039 721 69.99 Friends
41041 43 3.99 Friends
41042 42 3.99 Friends
41043 46 3.99 Friends
41035 277 29.99 Friends
41056 278 24.99 Friends
41037 369 39.99 Friends
41027 112 9.99 Friends
41028 78 9.99 Friends
21108 508 49.99 Ideas
library(plyr)
library(ggplot2)
raw <- read.csv("LEGO.csv", header=T)
raw$estimated.price <- raw$pieces / 10
raw$estimated.price.adjusted <- raw$pieces / 19
data2014 <- raw[c('price', 'estimated.price')]
data2014$year <- "2014"
data1989 <- raw[c('price', 'estimated.price.adjusted')]
data1989$year <- "1989"
names(data1989)[2] <- 'estimated.price'
forplot <- rbind(data1989, data2014)
qplot(price, estimated.price, data = forplot, color = year) +
geom_smooth() +
xlab("Price") + ylab("Estimated Price") +
theme(axis.text.y = element_text(face='bold', size=14),
axis.text.x = element_text(face='bold', size=14),
axis.title.y = element_text(face='bold', size=14),
axis.title.x = element_text(face='bold', size=14))
print(cor(raw$price, raw$estimated.price))
group.means <- ddply(raw, "collection", function(x) data.frame(mg = mean(x$price)))
group.cor <- ddply(raw, "collection", function(x) data.frame(gc = cor(x$price, x$estimated.price)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment