R/CombinedData-class.R

Defines functions CombinedData

#' @import fst

setClass("CombinedData", contains   = "data.table",
         slots = list(Acquisitions.path="character", Last_Performance.path="character"))

CombinedData <- function(Acquisitions.path, Last_Performance.path) {
  browser()
  stopifnot(file.exists(Acquisitions.path), file.exists(Last_Performance.path))
  # Data_A.fst_table <- fst[Acquisitions.path]
  # Last_P.fst_table <- fst[Last_Performance.path]
  Data_A <- read_fst(Acquisitions.path, columns = c('LOAN_ID', 'ORIG_DTE', 'ORIG_AMT'), as.data.table = TRUE)
  Last_P <- read_fst(Last_Performance.path, columns = c('LOAN_ID', 'last_upb'), as.data.table = TRUE)
  Combined_Data <- merge(Data_A, Last_P)

  new("CombinedData", Combined_Data, Acquisitions.path=Acquisitions.path, Last_Performance.path=Last_Performance.path)
}

#' show CombinedData
#'
#' show CombinedData data set
#'
#' @param object CombinedData
#'
#' @export
#'
setMethod("show", signature(object = "CombinedData"), function(object) {
  str(object, list.len=999)
  # print(asS3(object))
  print(metadata_fst(object@file_fst ))
  #  print(summary(object))
  callNextMethod()
})

#' aggregate CombinedData
#'
#' @param x CombinedData object
#' @param ... not used
#'
#' @return A data.table
#' @export
#'
setMethod("aggregate", signature(x = "CombinedData"), function(x,...) {
  aggregate.Combined_Data(x)
})
canarionyc/loanroll documentation built on Sept. 7, 2020, 4:50 a.m.