Data.Table Samples

  • In this post I am going to post some useful and handy data.table examples which I implemented in my codes.

Data.table cheat sheet link

  • Read list of files as a light speed: I had around 10k of same format csv files. Below code reads them incredibly fast.
    data_files <- list.files('../../../../../Data/', full.names = T, recursive = T, pattern = '.csv')
    l <- lapply(data_files, fread, sep = ',') #Read the files
    data <- rbindlist(l, fill = T)