R

How to combine files with R and add filename column

Here is a simple way how to combine CSV or text files with R and, at the same time, add a column with filenames. Here is all the code with more detailed explanations below.




I have 3 txt files, and each of them contains Tab-delimited movie data from IMDB.

To combine files with R and add filename column, follow these steps.

1. Read paths to files

2. Read file content

3. Read file names

4. Combine file content list with filename list

5. Unlist result and do some finalization

It is also possible to do that at once.

Please, check other R related posts that might be interesting for you.



0 comments on “How to combine files with R and add filename column

Leave a Reply

Your email address will not be published. Required fields are marked *