ageAtAcquisition.R (1284B)
1 # First stab at the MoMA data. I wondered if the museum would tend toward 2 # collecting older works as time went on. 3 4 require(dplyr) 5 require(tidyr) 6 require(ggplot2) 7 8 9 artworks <- read.csv("Artworks.csv", stringsAsFactors = FALSE) 10 11 # Just pull out the year, since dates aren't always formatted correctly. 12 artworks <- artworks %>% 13 filter(grepl("[0-9]{4}", DateAcquired), 14 grepl("[0-9]{4}", Date)) %>% 15 mutate(year_acquired = as.numeric(sub(".*([0-9]{4}).*", "\\1", DateAcquired)), 16 year_started = as.numeric(sub(".*([0-9]{4}).*", "\\1", Date)), 17 acquisition_age = year_acquired-year_started) %>% 18 filter(acquisition_age >= 0) 19 20 # Plot each work's age vs. its year of acquisition 21 ggplot(artworks, aes(x=year_acquired, y=acquisition_age)) + 22 geom_point(alpha = 0.01, position = position_jitter(w = 0.5, h = 0.5)) + 23 geom_smooth(se=FALSE, size=1.5) + 24 theme_minimal() + 25 scale_y_continuous(limits=c(0, 200)) + 26 scale_x_continuous(breaks=round(seq(min(artworks$year_acquired), 27 max(artworks$year_acquired), 28 length.out = 5))) + 29 labs(title="MoMA keeps things fresh", 30 y="Age (years) at time of acquisition", 31 x="Year acquired") 32 ggsave("age_at_acquisition.png")