I am reading my files into file_list
. The data is read using read.csv, however, I want the data in datalist
to have colnames as the file-names the file_list
. The original files does not have a header.
How do I change function(x)
so that the the second column has colname similar to the file-name. The first column does not have to be unique.
file_list = list.files(pattern="*.csv")
datalist = lapply(file_list, function(x){read.csv(file=x,header=F,sep = "\t")})