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:
df <- read.delim("PC120825150001_A1.Table.1.selections.txt", header = TRUE, sep = "\t")
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 :(((