I know there are several questions regarding the "apply one function to multiple data frames"-issue. However, I coundn't find a solution to my problem but I think I got close to it using a solution from this question: Same function over multiple data frames in R
I have 12 data frames with 4 columns each. The second one contains the data as an integer (e.g. 20161014, so %Y%m%d). To get it into 2016-10-14 I used
TX_SOUID100758.txt[,2]<-as.Date(as.character(TX_SOUID100758.txt[,2]), "%Y%m%d")
Since I want to apply this function on all 15 data frames I tried
zch_filelist <- list.files(path=path, pattern="*.txt")
for (file in zch_filelist){
assign(file, read.csv(paste(path, file, sep=''),na.strings = -9999))
}
lapply(zch_filelist, function(x) (as.Date(as.character(x[2]), "%Y%m%d")))
I used the previously created list of file names when I imported the files into R. However, it is not working. I guess the mistake is the indexing in the as.date function. Any help is greatly appreciated. Thanks!