Structuring data

After having acquired our target variable and knowing our dataset, we can now move on to the actual data collection based on our target. Here, we will try acquiring the data of the bank according to different years as described in the Collecting the target variable section.

To do this, we create a new variable extracting only the year when a bank went bankrupt, and then we count the number of banks by year:

failed_banks$year<-as.numeric(format(failed_banks$Closing.Date, "%Y"))  Failed_by_Year<-as.data.frame(table(failed_banks$year)) colnames(Failed_by_Year)<-c("year","Number_of_banks")  print(Failed_by_Year) ##    year Number_of_banks ## 1  2000               2 ## 2  2001               4 ## 3  2002              11 ## 4  2003               3 ## 5  2004               4 ## 6  2007               3 ## 7  2008              25 ## 8 ...

Get Machine Learning with R Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.