I wrote a simple function:
myfunction <- function(fileName, stringsAsFactors=TRUE, check.names=FALSE,
Like @Arun pointed out, you are trying to run your function twice: once on the files and once one the data frames you have created... Instead, your code should look like this:
files <- list.files(pattern = ".txt") mylist <- lapply(files, myfunction)