I have 52 files with same number of columns (5) with same titles (same headers), but different rows. I want to change one column named as "Hits" to the .csv file name itself.
for example filenames are 10235678.csv, 1405872.csv and so on. I want to change the "Hits" in the first csv as 10235678, and in the second csv - Hits column has to be changed into 1405872.
files_to_read <- list.files(pattern = ".csv", full.names = T) # reading all csv files in the directory into list of files. myfiles = lapply(files_to_read, read.delim, sep = ",") # The list is read into separate data frames with 5 columns in each csv files.
I can see that the myfiles has 52 files as separate data frame with 5 column and their column heading. I need to change one column named "Hits" into the file name itself.