Advertisement
kerillmp2

Untitled

Feb 9th, 2022
193
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Удаляем кварталы, если банк уже обанкротился
  2. ```{r}
  3. banks <- data.frame(banks_finance_sent_revoc[0,])
  4.  
  5. for (i in 1:nrow(banks_finance_sent_revoc)) {
  6.   row <- banks_finance_sent_revoc[i,]
  7.   if (row$Revoc_Quarter != '0') {
  8.     quarter_year <- as.numeric(substring(row$Quarter, 1, 4))
  9.     quarter_q <- as.numeric(substring(row$Quarter, 6, 7))
  10.     revoc_quarter_year <- as.numeric(substring(row$Revoc_Quarter, 1, 4))
  11.     revoc_quarter_q <- as.numeric(substring(row$Revoc_Quarter, 6, 7))
  12.     if (quarter_year < revoc_quarter_year || (quarter_year == revoc_quarter_year && quarter_q <= revoc_quarter_q)) {
  13.       banks <<- rbind(banks, row)
  14.     }
  15.   } else {
  16.     banks <<- rbind(banks, row)
  17.   }
  18. }
  19. ```
Advertisement
RAW Paste Data Copied
Advertisement