├── .gitignore ├── 100charts.Rproj ├── cpi.csv ├── population.csv ├── us_gov_receipts_expenditures.csv └── 100charts.R /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | charts 6 | .DS_Store 7 | data.csv 8 | -------------------------------------------------------------------------------- /100charts.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | -------------------------------------------------------------------------------- /cpi.csv: -------------------------------------------------------------------------------- 1 | year,cpi 1913,9.9 1914,10 1915,10.1 1916,10.9 1917,12.8 1918,15.1 1919,17.3 1920,20 1921,17.9 1922,16.8 1923,17.1 1924,17.1 1925,17.5 1926,17.7 1927,17.4 1928,17.1 1929,17.1 1930,16.7 1931,15.2 1932,13.7 1933,13 1934,13.4 1935,13.7 1936,13.9 1937,14.4 1938,14.1 1939,13.9 1940,14 1941,14.7 1942,16.3 1943,17.3 1944,17.6 1945,18 1946,19.5 1947,22.3 1948,24.1 1949,23.8 1950,24.1 1951,26 1952,26.5 1953,26.7 1954,26.9 1955,26.8 1956,27.2 1957,28.1 1958,28.9 1959,29.1 1960,29.6 1961,29.9 1962,30.2 1963,30.6 1964,31 1965,31.5 1966,32.4 1967,33.4 1968,34.8 1969,36.7 1970,38.8 1971,40.5 1972,41.8 1973,44.4 1974,49.3 1975,53.8 1976,56.9 1977,60.6 1978,65.2 1979,72.6 1980,82.4 1981,90.9 1982,96.5 1983,99.6 1984,103.9 1985,107.6 1986,109.6 1987,113.6 1988,118.3 1989,124 1990,130.7 1991,136.2 1992,140.3 1993,144.5 1994,148.2 1995,152.4 1996,156.9 1997,160.5 1998,163 1999,166.6 2000,172.2 2001,177.1 2002,179.9 2003,184 2004,188.9 2005,195.3 2006,201.6 2007,207.342 2008,215.303 2009,214.537 2010,218.056 2011,224.939 2012,229.594 2013,232.957 2014,236.736 2015,237.017 2016,240.007 -------------------------------------------------------------------------------- /population.csv: -------------------------------------------------------------------------------- 1 | year,population 2016,323127513 2015,320896618 2014,318563456 2013,316204908 2012,313998379 2011,311663358 2010,309348193 2009,306771529 2008,304093966 2007,301231207 2006,298379912 2005,295516599 2004,292805298 2003,290107933 2002,287625193 2001,284968955 2000,282162411 1999,272690813 1998,270248003 1997,267783607 1996,265228572 1995,262803276 1994,260327021 1993,257782608 1992,255029699 1991,252153092 1990,249464396 1989,246819230 1988,244498982 1987,242288918 1986,240132887 1985,237923795 1984,235824902 1983,233791994 1982,231664458 1981,229465714 1980,227224681 1979,225055487 1978,222584545 1977,220239425 1976,218035164 1975,215973199 1974,213853928 1973,211908788 1972,209896021 1971,207660677 1970,205052174 1969,202676946 1968,200706052 1967,198712056 1966,196560338 1965,194302963 1964,191888791 1963,189241798 1962,186537737 1961,183691481 1960,180671158 1959,177829628 1958,174881904 1957,171984130 1956,168903031 1955,165931202 1954,163025854 1953,160184192 1952,157552740 1951,154877889 1950,152271417 1949,149188130 1948,146631302 1947,144126071 1946,141388566 1945,139928165 1944,138397345 1943,136739353 1942,134859553 1941,133402471 1940,132122446 1939,130879718 1938,129824939 1937,128824829 1936,128053180 1935,127250232 1934,126373773 1933,125578763 1932,124840471 1931,124039648 1930,123076741 1929,121767000 1928,120509000 1927,119035000 1926,117397000 1925,115829000 1924,114109000 1923,111947000 1922,110049000 1921,108538000 1920,106461000 1919,104514000 1918,103208000 1917,103268000 1916,101961000 1915,100546000 1914,99111000 1913,97225000 1912,95335000 1911,93863000 1910,92407000 1909,90490000 1908,88710000 1907,87008000 1906,85450000 1905,83822000 1904,82166000 1903,80632000 1902,79163000 1901,77584000 1900,76094000 -------------------------------------------------------------------------------- /us_gov_receipts_expenditures.csv: -------------------------------------------------------------------------------- 1 | year,Current tax receipts,Personal current taxes,Taxes on production and imports,Taxes on corporate income,Current transfer payments,Government social benefits,To persons,To the rest of the world 2 | 1929,9.9,1.7,6.8,1.4,0.8,0.8,0.8, 3 | 1930,9.4,1.6,7,0.8,0.9,0.9,0.9, 4 | 1931,8.2,1,6.7,0.5,2,1.9,1.9, 5 | 1932,7.7,0.7,6.6,0.4,1.3,1.3,1.3, 6 | 1933,8.2,0.8,6.9,0.5,1.3,1.3,1.3, 7 | 1934,9.3,0.9,7.6,0.7,1.4,1.3,1.3, 8 | 1935,10,1.1,8,1,1.6,1.6,1.6, 9 | 1936,11.2,1.3,8.5,1.4,2.7,2.7,2.7, 10 | 1937,12.4,1.9,8.9,1.5,1.7,1.6,1.6, 11 | 1938,11.8,1.9,8.9,1,2.2,2.1,2.1, 12 | 1939,12.1,1.5,9.1,1.4,2.3,2.2,2.2, 13 | 1940,14.3,1.7,9.8,2.8,2.4,2.4,2.4, 14 | 1941,21,2.3,11.1,7.6,2.3,2.3,2.3, 15 | 1942,27.8,4.9,11.5,11.4,2.4,2.3,2.3, 16 | 1943,43.2,16.7,12.4,14.1,2,2.1,2.1, 17 | 1944,44.3,17.7,13.7,12.9,2.6,2.7,2.7, 18 | 1945,45.2,19.4,15.1,10.7,5.5,5.1,5.1, 19 | 1946,43.1,17.2,16.8,9.1,12.4,10.1,10.1, 20 | 1947,49.2,19.8,18.1,11.3,12.4,10.4,10.4, 21 | 1948,51.4,19.2,19.7,12.4,13.7,9.9,9.9, 22 | 1949,47.8,16.7,20.9,10.2,16,10.9,10.9, 23 | 1950,59.8,18.9,23,17.9,17,13.4,13.4, 24 | 1951,74.4,27.1,24.7,22.6,13.7,10.5,10.5, 25 | 1952,78.5,32,27.1,19.4,13.2,11,11, 26 | 1953,82.6,33.2,29.1,20.3,13.7,11.7,11.7, 27 | 1954,76.7,30.2,28.9,17.6,15.6,13.7,13.7, 28 | 1955,86.4,32.9,31.5,22,16.9,14.8,14.8, 29 | 1956,92.8,36.6,34.2,22,17.6,15.6,15.6, 30 | 1957,96.9,38.9,36.6,21.4,20.1,18.1,18.1, 31 | 1958,95.2,38.5,37.7,19,24.2,22.2,22.2, 32 | 1959,107.1,42.3,41.1,23.6,26.9,22.9,22.9, 33 | 1960,113.4,46.1,44.5,22.7,28.1,24.7,24.4,0.2 34 | 1961,117.1,47.3,47,22.8,31.9,28.4,28.1,0.3 35 | 1962,126.1,51.6,50.4,24,32.8,29.1,28.8,0.3 36 | 1963,134.4,54.6,53.4,26.2,34.3,30.7,30.3,0.3 37 | 1964,137.5,52.1,57.3,28,35.1,31.7,31.3,0.3 38 | 1965,149.5,57.7,60.7,30.9,38,34.4,33.9,0.5 39 | 1966,163.5,66.4,63.2,33.7,42,38,37.5,0.5 40 | 1967,173.8,73,67.9,32.7,50.3,46.3,45.8,0.6 41 | 1968,203.1,87,76.4,39.4,58.4,53.9,53.3,0.6 42 | 1969,228.4,104.5,83.9,39.7,64.1,59.6,59,0.6 43 | 1970,229.2,103.1,91.4,34.4,77.3,72.5,71.7,0.7 44 | 1971,240.3,101.7,100.5,37.7,92.2,86.2,85.4,0.8 45 | 1972,273.8,123.6,107.9,41.9,103,95.8,94.8,1 46 | 1973,299.3,132.4,117.2,49.3,115.2,109.8,108.6,1.2 47 | 1974,328.1,151,124.9,51.8,135.9,129.9,128.6,1.3 48 | 1975,334.3,147.6,135.3,50.9,171.3,165.1,163.1,2 49 | 1976,384,172.7,146.4,64.2,184.7,180.1,177.6,2.5 50 | 1977,431.3,197.9,159.7,73,196.3,192.1,189.5,2.6 51 | 1978,485,229.6,170.9,83.5,211.2,206.2,203.4,2.7 52 | 1979,538.2,268.9,180.1,88,236.2,230.4,227.3,3 53 | 1980,586.2,299.5,200.3,84.8,282.4,275,271.5,3.5 54 | 1981,664.1,345.8,235.6,81.1,318.8,312.1,307.8,4.3 55 | 1982,660.1,354.7,240.9,63.1,355.3,347.2,343.1,4.1 56 | 1983,694.6,352.9,263.3,77.2,383.1,374.1,370.5,3.6 57 | 1984,763,377.9,289.8,94,395.8,384.6,380.9,3.7 58 | 1985,824.4,417.8,308.1,96.5,420.9,407.1,403.1,4 59 | 1986,869.4,437.8,323.4,106.5,447.2,433,428.6,4.4 60 | 1987,966.3,489.6,347.5,127.1,464.9,452.2,447.9,4.3 61 | 1988,1019.9,505.9,374.5,137.2,494.6,481.4,476.9,4.6 62 | 1989,1110.8,567.7,398.9,141.5,539.7,526.2,521.1,5.1 63 | 1990,1163.3,594.7,425,140.6,594.4,580.8,574.7,6.2 64 | 1991,1182.2,588.9,457.1,133.6,631.2,656.8,650.5,6.3 65 | 1992,1242,612.8,483.4,143.1,758.5,738,731.8,6.2 66 | 1993,1320,648.8,503.1,165.4,806.8,785.1,778.9,6.2 67 | 1994,1428.2,693.1,545.2,186.7,842.5,822.5,815.7,6.8 68 | 1995,1521.2,748.4,557.9,211,886.9,871.5,864.7,6.8 69 | 1996,1646.6,837.1,580.8,223.6,934.3,913.9,906.3,7.6 70 | 1997,1785.7,931.8,611.6,237.1,960.2,943.3,935.4,7.9 71 | 1998,1916.7,1032.4,639.5,239.2,984.1,966.1,957.9,8.2 72 | 1999,2040.4,1112.1,673.6,248.8,1019.5,1000.7,992.2,8.5 73 | 2000,2207.1,1236.6,708.6,254.7,1075.9,1053.5,1044.9,8.7 74 | 2001,2168.2,1239.3,727.7,193.5,1173.5,1155.3,1145.8,9.4 75 | 2002,2006.2,1054.7,762.6,181.3,1283.5,1260.1,1250.5,9.7 76 | 2003,2054.1,1005.3,808,231.8,1359.8,1331.2,1321.1,10.1 77 | 2004,2216.5,1050.6,863.9,292,1446,1415.2,1404.6,10.7 78 | 2005,2555.8,1213.2,934.5,395.9,1543.1,1502.3,1491,11.2 79 | 2006,2817.9,1357.1,991.9,454.3,1640.5,1605.5,1593.1,12.4 80 | 2007,2963.8,1493.2,1034.6,420.7,1753.1,1710.8,1697.5,13.3 81 | 2008,2849.6,1507.8,1041.9,281.1,1980.5,1935.4,1920,15.5 82 | 2009,2439.2,1152.3,1026.1,246,2177.5,2124.9,2108.8,16 83 | 2010,2658.4,1239.3,1057.1,346.3,2351.8,2298.3,2281.7,16.5 84 | 2011,2922.1,1453.2,1102.6,349.6,2384.9,2327.3,2310.2,17.1 85 | 2012,3077.2,1511.4,1132.1,415.6,2396.9,2341.5,2323.6,18 86 | 2013,3305.6,1677.8,1174.9,433.5,2459.6,2405.7,2386.9,18.9 87 | 2014,3513.8,1787,1210.2,495.2,2566.8,2514.4,2494.9,19.5 88 | 2015,3713.9,1938.7,1237.6,515.4,2699.6,2647.6,2627.2,20.4 89 | 2016,3749.1,1965.6,1256.2,504.1,2796.3,2743,2722.1,20.9 90 | -------------------------------------------------------------------------------- /100charts.R: -------------------------------------------------------------------------------- 1 | library(dplyr) 2 | library(ggplot2) 3 | library(readr) 4 | 5 | # Data is a subset of the "Government Current Receipts and Expenditures" table 6 | # From the Bureau of Economic Analysis 7 | # https://www.bea.gov/iTable/iTable.cfm?ReqID=9&step=1#reqid=9&step=3&isuri=1&904=1929&903=86&906=a&905=2016&910=x&911=0 8 | data <- read_csv("us_gov_receipts_expenditures.csv", col_types="idddddddd") 9 | 10 | # Simplify labels 11 | colnames(data) <- c( 12 | "year", 13 | "receipts", 14 | "receipts.personal_taxes", 15 | "receipts.production_taxes", 16 | "receipts.transfer_payments", 17 | "social_benefits", 18 | "social_benefits.to_persons", 19 | "social_benefits.to_world" 20 | ) 21 | 22 | # CPI is from Bureau of Labor Statistics series CUUR0000SA0 annual averages 23 | # https://data.bls.gov/timeseries/CUUR0000SA0 24 | cpi <- read_csv("cpi.csv", col_types="id") 25 | 26 | cpi.base <- cpi[cpi$year == 2016,]$cpi 27 | 28 | data <- data %>% 29 | left_join(cpi, by="year") 30 | 31 | # US population totals are from census historical and intercensal estimates 32 | population <- read_csv("population.csv", col_types="id") 33 | 34 | data <- data %>% 35 | left_join(population, by="year") 36 | 37 | i = 0 38 | 39 | # Shortcut for generating a simple line chart 40 | line.chart <- function(title, y, y.label, zero.line = FALSE) { 41 | plot <- ggplot(data=data, aes_string(x="year", y=y)) + 42 | labs(title = title, x = "Year", y = y.label) + 43 | scale_x_continuous(breaks = c(1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000, 2010)) + 44 | geom_line() 45 | 46 | if (zero.line) { 47 | plot + geom_hline(yintercept = 0, color="#666666") 48 | } 49 | 50 | ggsave( 51 | paste("charts/", i, ".", y, ".jpg", sep=""), 52 | width = 6, 53 | height = 6 * 9 / 16, 54 | dpi = 300 55 | ) 56 | 57 | i <<- i + 1 58 | } 59 | 60 | ### 61 | ### MEASURES OF VALUE 62 | ### 63 | 64 | # Nominal 65 | data$nominal <- data$receipts.personal_taxes 66 | 67 | line.chart( 68 | "Nominal personal tax receipts", 69 | "nominal", 70 | "Dollars" 71 | ) 72 | 73 | # Real 74 | data$real <- data$nominal * cpi.base / data$cpi 75 | 76 | line.chart( 77 | "Real personal tax receipts", 78 | "real", 79 | "Constant 2016 dollars" 80 | ) 81 | 82 | # In units of TKTK (price of some common good, e.g. Big Macs) 83 | # TKTK 84 | 85 | # Real rate per capita 86 | data$per.capita <- data$real / data$population 87 | 88 | line.chart( 89 | "Real personal tax receipts per capita", 90 | "per.capita", 91 | "Constant 2016 dollars" 92 | ) 93 | 94 | # Real deviation from mean 95 | data$dev.from.mean <- data$real - mean(data$real) 96 | 97 | line.chart( 98 | "Real deviation from all-time average tax", 99 | "dev.from.mean", 100 | "Constant 2016 dollars", 101 | zero.line = TRUE 102 | ) 103 | 104 | # Real deviation from base period mean 105 | data$dev.from.period <- data$real - mean(data[data$year >= 1980 & data$year < 1990,]$real) 106 | 107 | line.chart( 108 | "Real deviation from 1980's average", 109 | "dev.from.period", 110 | "Constant 2016 dollars", 111 | zero.line = TRUE 112 | ) 113 | 114 | # Z-Scores 115 | # TKTK 116 | 117 | ### 118 | ### MEASURES OF CHANGE 119 | ### 120 | 121 | # Real year-over-year change 122 | data <- data %>% 123 | mutate(yoy = real - lag(real)) 124 | 125 | line.chart( 126 | "Real year-over-year change in personal tax receipts", 127 | "yoy", 128 | "Constant 2016 dollars", 129 | zero.line = TRUE 130 | ) 131 | 132 | # Real year-over-year percent change 133 | data <- data %>% 134 | mutate(pct.change = real / lag(real)) 135 | 136 | line.chart( 137 | "Real year-over-year percent change in personal tax receipts", 138 | "pct.change", 139 | "%", 140 | zero.line = TRUE 141 | ) 142 | 143 | # Cumulative percent change 144 | data <- data %>% 145 | mutate(cum.pct.change = real / first(real)) 146 | 147 | line.chart( 148 | "Real percent change in personal tax receipts since 1929", 149 | "cum.pct.change", 150 | "%" 151 | ) 152 | 153 | # Real index to initial year 154 | data <- data %>% 155 | mutate(index = real / (first(real) / 100)) 156 | 157 | line.chart( 158 | "Indexed real change in personal tax receipts", 159 | "cum.pct.change", 160 | "Index value (1929 = 100)" 161 | ) 162 | 163 | # Real index to low year 164 | # TKTK 165 | 166 | # Real index to high year 167 | base <- data[data$year == 1945,]$real 168 | 169 | data <- data %>% 170 | mutate(index.high = real / (base / 100)) 171 | 172 | line.chart( 173 | "Indexed real change in personal tax receipts", 174 | "index.high", 175 | "Index value (1945 = 100)" 176 | ) 177 | 178 | ### 179 | ### MEASURES OF PROPORTION 180 | ### 181 | 182 | # Share of receipts 183 | data$share.of.receipts <- data$nominal / data$receipts * 100 184 | 185 | # Change in share of receipts 186 | data <- data %>% 187 | mutate(share.change = share.of.receipts - first(share.of.receipts)) 188 | 189 | # Year-over-year change in share of receipts 190 | data <- data %>% 191 | mutate(share.yoy = share.of.receipts - lag(share.of.receipts)) 192 | 193 | ### 194 | ### Other 195 | ### 196 | 197 | # Volatility 198 | # TKTK 199 | 200 | # Stash all transformations for easy review 201 | write_csv(data, "data.csv") 202 | 203 | --------------------------------------------------------------------------------