Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added FDIC files.
  • Loading branch information
ezgraphs committed Aug 24, 2010
1 parent d42532d commit 6f8a025
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 0 deletions.
45 changes: 45 additions & 0 deletions data/fdic.csv
@@ -0,0 +1,45 @@
, Statistics At A Glance,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Historical Trends,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,," As of March 31, 2010",,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Dollar Amounts in Billions,,2010 YTD,2009,,2008,,2007,2006,,2005,,2004,,2003,,2002,,2001,,2000,,1999,,1998,,1997,,1996,,1995,,1994,,1993,,1992,,1991,,1990,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Commercial Banks,,"6,772","6,839",,"7,086",,"7,283","7,401",,"7,526",,"7,631",,7770,,"7,888",,"8,080",,"8,315 ",,"8,580 ",,"8,774 ",,"9,143 ",,"9,528 ",,"9,941 ",,"10,452 ",,"10,959 ",,"11,463 ",,"11,921 ",,"12,343 ",
New Charters,,2,25,,89,,164,178,,166,,122,,110,,91,,126,,190 ,,230 ,,188 ,,187 ,,145 ,,102 ,,50 ,,58 ,,72 ,,105 ,,163 ,
Mergers,,33,152,,261,,282,305,,269,,261,,224,,276,,354,,452 ,,416 ,,557 ,,598 ,,552 ,,606 ,,548 ,,501 ,,425 ,,443 ,,389 ,
,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,
Savings Institutions,,"1,160","1,173",,"1,219",,"1,251","1,279",,"1,307",,"1,345",,"1,411",,"1,466",,"1,534",,"1,589 ",,"1,642 ",,"1,690 ",,"1,780 ",,"1,926 ",,"2,030 ",,"2,152 ",,"2,262 ",,"2,390 ",,"2,561 ",,"2,815 ",
New Charters,,1,6,,9,,17,16,,13,,6,,8,,4,,20,,33 ,,40 ,,33 ,,12 ,,12 ,,9 ,,18 ,,9 ,,8 ,,9 ,,28 ,
Mergers,,4,27,,32,,39,37,,41,,58,,49,,56,,63,,81 ,,80 ,,114 ,,127 ,,108 ,,116 ,,109 ,,111 ,,84 ,,72 ,,64 ,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Problem Institutions,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,
Number,,775,702,,252,,76,50,,52,,80,,116,,136,,114,,94,,79,,84,,92,,117 ,,193 ,,318 ,,575 ,,"1,066 ",,"1,430 ",,"1,496 ",
Assets,$,431,403,,159,,22,8,,7,,28,,30,,39,,40,,24,,10,,11,,6,,12 ,,31 ,,73 ,,348 ,,601 ,,837 ,,647 ,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Combined Dep. Ins. Fund,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Fund Balance,$,-20.7,-20.9,,17.3,,52.4,50.2,,48.6,,47.5,,46.0,,43.8,,41.4,,41.7,,39.7,,39.4,,37.7,,35.7,,28.8,,23.8,,14.3,,0.2,,-6.9,,4.1,
Insured Deposits,$,"5,463","5,392",,"4,749",,"4,292","4,154",,"3,891",,"3,622",,"3,452",,"3,384",,"3,211",,"3,055",,"2,869",,"2,850",,"2,746",,"2,691",,"2,664",,"2,589",,"2,602",,"2,675",,"2,734",,"2,760",
Reserve Ratio,%,-0.38,-0.39,,0.36,,1.22,1.21,,1.25,,1.31,,1.33,,1.29,,1.29,,1.36,,1.38,,1.38,,1.37,,1.33,,1.08,,0.92,,0.55,,0.01,,-0.25,,0.15,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Number Failed Institutions,,41,140,,25,,3,0,,0,,4,,3,,11,,4,,7,,8,,3,,1,,6,,8,,15,,50,,179,,268,,381,
Failed Assets*,$,22.140,169.709,,371.945,,2.615,0.000,,0.000,,0.170,,0.947,,3.383,,1.821,,0.414,,1.592,,0.290,,0.028,,0.233,,1.226,,1.601,,9.977,,89.554,,143.455,,146.586,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Number Assisted Institutions,,0,8,,5,,0,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,2,,3,,1,
Assisted Assets*,$,0.000,"1,917.482",,"1,306.042",,0.000,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.034,,0.079,,0.014,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Estimated Losses(DIF),$,6.305,35.615,,17.982,,0.120,0.000,,0.000,,0.004,,0.066,,0.376,,0.271,,0.032,,0.616,,0.226,,0.005,,0.061,,0.113,,0.194,,0.698,,7.447,,15.120,,22.030,
Resolution Receivables**,$,39.091,37.288,,15.766,,0.808,0.482,,0.533,,0.722,,0.784,,0.793,,1.429,,0.354,,0.805,,0.757,,1.114,,4.45,,4.143,,8.197,,13.396,,27.824,,18.675,,12.935,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Number of FDIC Employees***,,"6,822","6,558",,"4,988",,"4,532","4,476",,"4,514",,"5,078",,"5,311",,"5,430",,"6,167",,"6,452 ",,"7,266 ",,"7,359 ",,"7,793 ",,"9,151 ",,"11,856 ",,"17,526 ",,"20,994 ",,"22,459 ",,"22,586 ",,"19,247 ",
(Includes RTC before 1996),,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
* Prior years have been revised to reflect failed/assisted assets as reported on the Call Report for the quarter prior to failure/assistance.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
** Includes remaining receivership assets from prior years,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
"*** Beginning in 2008, FDIC began reporting the number of FDIC employees based on a new, full-time eqivalent methodology.",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Prior years have been revised to reflect the number of employees as reported in the FDIC Annual Report.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,




,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
101 changes: 101 additions & 0 deletions fdic.R
@@ -0,0 +1,101 @@
# http://www.fdic.gov/bank/statistical/stats/2010mar/fdic.xls
# File --> Save As .csv

df=read.csv('data/fdic.csv',header=TRUE, skip=4)
head(df)

# Remove Empty Columns
df=df[c(-2,-5,-7,-10,-12,-14,-16,-18,-20,-22,-24,-26,-28,-30,-32,-34,-36,-38,-40,-42)]

# Remove Rows with Trailing information
df=df[-(29:36),]

# fix the column names
colnames(df)=gsub('X','',colnames(df))
colnames(df)=gsub('X','',colnames(df))
colnames(df)[1]='Statistic'
colnames(df)[2]='2010' # But remember this is YTD

# I am kind of fuzzy about the rules - but it seems like you just have to try casting columns as factors in one
# context and as characters in another to get the desired result. If there is a set rule about usage, please let
# me know. At this point, I am accepting that these types are not handled in a consistent way and you just have
# to know how a particular function behaves.
#
df$Statistic=as.character(df$Statistic)

# Trim leading white space
df$Statistic=gsub('^ *','',df$Statistic)

# Remove Subheadings - include them inline
# Could do this by explicit naming
df$Statistic[11]='Problem Institutions Number'
df$Statistic[12]='Problem Institutions Assets'

# This is a bit more generic
df$Statistic[3]=paste(df$Statistic[2],df$Statistic[3])
df$Statistic[4]=paste(df$Statistic[2],df$Statistic[4])
df$Statistic[7]=paste(df$Statistic[6],df$Statistic[7])
df$Statistic[8]=paste(df$Statistic[6],df$Statistic[8])
df$Statistic[15]=paste(df$Statistic[14],df$Statistic[15])
df$Statistic[16]=paste(df$Statistic[14],df$Statistic[16])
df$Statistic[17]=paste(df$Statistic[14],df$Statistic[17])

# Remove Rows with no data (Empty Rows and Subheading Rows)
df=df[c(-1,-5,-9,-10,-13,-14,-18,-21,-24, -27),]

# At this point, we have the actual statistical data isolated.
# However, it would easier use the data if it were pivotted.

# You can quickly pivot by transposing it - but the result is a matrix full of string data
t(df)

# Better to use the reshape package
library(reshape)
df.melted=melt(df, id="Statistic")

# Strip out all commas and cast the values to numerics. Keep in mind, there are $ amounts and % for different stats
df.melted$value=as.numeric(gsub(',','',as.character(df.melted$value)))
colnames(df.melted)[2]='Year'
df.melted$Year=as.numeric(as.character(df.melted$Year))

# Pretty much done with the data set as a whole. Now create subsets:
fdic_employees= df.melted[df$Statistic=='Number of FDIC Employees***',c('Year','value')]
fdic_employees$Year=factor(fdic_employees$Year)
fdic_employees$value=factor(fdic_employees$value)
colnames(fdic_employees)=c('Year','Number')

# Can break up into individual series
df$Statistic
pin=df.melted[df.melted$Statistic=="Problem Institutions Number",]
cb= df.melted[df.melted$Statistic=="Commercial Banks",]
si=df.melted[df.melted$Statistic=="Savings Institutions",]

# Another way to manipulate data frames is using sqldf
# The following compares several of the series with eachother.
library('sqldf')

pct_prob=sqldf('SELECT
p.Year Year,
p.value prob, c.value + s.value "Total Institutions",
p.value / (c.value + s.value) * 100 "Percent Problem"
FROM pin p
JOIN cb c ON c.Year = p.Year
JOIN si s ON s.Year = p.Year')

library(ggplot2)
p = qplot(data=pct_prob, Year, `Percent Problem`, color=`Total Institutions`, group=1)
p = p + geom_line()
p + opts(axis.text.x=theme_text(angle=-90, hjust=0), title='Total FDIC Problem Institutions by Year')
ggsave('totalFDICProblemInstitutionsByYear.png')

fdicPlot=function(statistic){

f=df.melted[df.melted$Statistic==statistic,]
ggplot(data=f, aes(x=Year, y=value)) + geom_line() + geom_point() + opts(title=statistic)
img=paste(gsub(" |\\(|\\)|\\*",'',i),'.png',sep='')
ggsave(img)

}

for (i in df$Statistic){fdicPlot(i)}
dev.off()

0 comments on commit 6f8a025

Please sign in to comment.