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))
我的read.table()
中有一个stackfiles()
,它会读取a-g.list
内的每个文件。如何使用apply()重写这种格式,因为我意识到我不能避免为每次重复分配一个新的变量名,但同时,我还需要增加[[i]],即很难解决这个问题。