When importing CSV into R how to generate column with name of the CSV?

后端 未结 6 586
情书的邮戳
情书的邮戳 2020-12-01 06:45

I have a large number of csv files that I want to read into R. All the Column headings in the csvs are the same. At first I thought I would need to create a loop based on th

6条回答
  •  独厮守ぢ
    2020-12-01 07:24

    Try this:

    do.call("rbind", sapply(filenames, read.csv, simplify = FALSE))
    

    The row names will indicate the source and line number.

提交回复
热议问题