I have multiple data frames that I read from a bunch of txt files in a folder using the easycsv package. Now I want to merge all the data frames together into one, but first I need to add a unique identifier variable to each data frame. Each data frame contains data from one participant. The number of rows for each data frame varies between participants. The participant number is 2 to 3 digits long and always directly follows the characters "VP" in the file name. How can I extract the participant number from the file name and add it as a new column to the data frames, preferrably in one go? I would really appreciate any help in this issue!
You can use something like this, I cant test the solution since you are not providing any sample of the data or file names so you will have to adapt it to your actual scenario.
Thanks for your help! I ended up solving this problem a different way and it overlapped with your reply. Sorry about that! I wish I had the energy to test your solution, but I'm having trouble doing other really basic stuff in R just to give you an idea of the level of beginner you're dealing with.