I am very VERY new to R and coding. I have imported a .txt file into RStudio but need to add a new column to this data frame with the filename. My code so far:
I would like the new column to be filled with 'PC120825150001_A1.Table.1.selections.txt'. Or better yet, just 'PC120825150001'. I have 100's of txt files to convert and plan to create a loop to go through the folder with all the txt files in it.
I have successfully made a new column using df$File <- " ", but not sure what to put in " "
I'm sure it's a quick fix, but I am pulling my hair out :(((
If you're reading in a directory of files (or just a bunch of files that you can put all in one place), there's a nice way to do this with the purrr package described in the following blog post: