items = c("a", "b", "c", "d", "e", "f", "g")
a = lapply(items, function(items) list.files(pattern=paste0(items,".*\\.txt")))
a.df = do.call("rbind", lapply(a[[1]], stackfiles))
b.df = do.call("rbind", lapply(a[[2]], stackfiles))
c.df = do.call("rbind", lapply(a[[3]], stackfiles))
d.df = do.call("rbind", lapply(a[[4]], stackfiles))
e.df = do.call("rbind", lapply(a[[5]], stackfiles))
f.df = do.call("rbind", lapply(a[[6]], stackfiles))
g.df = do.call("rbind", lapply(a[[7]], stackfiles))
There's a read.table()
inside my stackfiles()
which will read through every file that is inside the a-g.list
. How can I use the apply() to rewrite the this format, because I realized I cant avoid assigning a new variable name for each repetition, but also at the same time, I also need to increment a[[i]], that is hard part this problem.