1

How I can extend belowed code to add an additional column with file name:

library(data.table)
files = list.files(pattern="*.csv")
DT = do.call(rbind, lapply(files, fread)

Or maybe is a better way to do it?

I need to load many files into one data.table with information about source file.

Kulis
  • 988
  • 3
  • 11
  • 25
  • 1
    Possible duplicate: https://stackoverflow.com/q/44462494/2572423 – JasonAizkalns Mar 04 '18 at 20:48
  • 3
    I think [this answer](https://stackoverflow.com/a/45522323/1851712) by @Uwe does what you want. See also [this nice workflow](http://franknarf1.github.io/r-tutorial/_book/tables.html#rbindlist-read). – Henrik Mar 04 '18 at 21:01

0 Answers0