Skip to content

Instantly share code, notes, and snippets.

@wrathematics
Created April 3, 2020 17:07
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 wrathematics/bcea567b312d3a1afeabdf614782b142 to your computer and use it in GitHub Desktop.
Save wrathematics/bcea567b312d3a1afeabdf614782b142 to your computer and use it in GitHub Desktop.
monthly NICS background checks
We can make this file beautiful and searchable if this error is corrected: It looks like row 24 should actually have 14 columns, instead of 13. in line 23.
Year,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,Totals
1998,,,,,,,,,,,,871644,892840
1999,591355,696323,753083,646712,576272,569493,589476,703394,808627,945701,1004333,1253354,9138123
2000,639972,707070,736543,617689,538648,550561,542520,682501,782087,845886,898598,1000962,8543037
2001,640528,675156,729332,594723,543501,540491,539498,707288,864038,1029691,983186,1062559,8910191
2002,665803,694668,714665,627745,569247,518351,535594,693139,724123,849281,887647,974059,8454322
2003,653751,708281,736864,622832,567436,529334,533289,683517,738371,856863,842932,1008118,8481588
2004,695000,723654,738298,642589,542456,546847,561773,666598,740260,865741,890754,1073301,8687671
2005,685811,743070,768290,658954,557058,555560,561358,687012,791353,852478,927419,1164382,8952945
2006,775518,820679,845219,700373,626270,616097,631156,833070,919487,970030,1045194,1153840,10036933
2007,894608,914954,975806,840271,803951,792943,757884,917358,944889,1025123,1079923,1230525,11177335
2008,942356,1021130,1040863,940961,886183,819891,891224,956872,973003,1183279,1529635,1523426,12709023
2009,1213885,1259078,1345096,1225980,1023102,968145,966162,1074757,1093230,1233982,1223252,1407155,14033824
2010,1119229,1243211,1300100,1233761,1016876,1005876,1069792,1089374,1145798,1368184,1296223,1521192,14409616
2011,1323336,1473511,1449724,1351255,1230953,1168322,1157041,1310041,1253752,1340273,1534414,1862327,16454951
2012,1377301,1749903,1727881,1427343,1316226,1302660,1300704,1526206,1459363,1614032,2006919,2783765,19592303
2013,2495440,2309393,2209407,1714433,1435917,1281351,1283912,1419088,1401362,1687599,1813643,2041528,21093273
2014,1660355,2086863,2488842,1742946,1485159,1382975,1401228,1546497,1456032,1603469,1803397,2309684,20968547
2015,1772794,1859584,2012488,1711340,1380980,1529057,1600832,1745410,1795102,1976759,2243030,3314394,23141970
2016,2545802,2613074,2523265,2145865,1870000,2131485,2197169,1853815,1991219,2333339,2561281,2771159,27538673
2017,2043184,2234817,2433092,2045564,1942677,1901768,1742346,1925146,1967104,2030391,2382788,2586138,25235215
2018,2030330,2333193,2767699,2223213,2002992,1935691,1835318,2073296,1956681,2086895,2393043,2543385,26181936
2019,2165094,2053886,2644851,2334249,2349309,2312309,2030661,2366824,2207312,2393609,2374752,2936894,28369750
2020,2702302,2802467,3740688,,,,,,,,,
# Data from https://www.fbi.gov/file-repository/nics_firearm_checks_-_month_year.pdf/view
library(reshape2)
x = read.csv("nics.csv", sep=",")
x$Totals = NULL
mx = melt(x, id.vars="Year")
mx$Date = as.Date(paste("01", mx$variable, mx$Year), format="%d %b %Y")
library(ggplot2)
library(scales)
ggplot(mx, aes(Date, value)) +
theme_bw() +
geom_line() +
xlab("") +
ylab("") +
scale_y_continuous(labels=comma) +
ggtitle("Monthly NICS Firearm Background Checks")
ggsave(last_plot(), file="nics.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment