Using lapply to apply a function over list of data frames and saving output to files with different names

余生长醉 提交于 2019-11-28 04:59:08

It will work with the following lapply call:

lapply(names(mylist), function(x) NewVar(mylist[[x]], "y", x))

There are many options. For example:

  lapply(names(mylist),
         function(x)write.csv(mylist[x],
                              file =paste0(x,'.csv')))

or using indexes :

 lapply(seq_along(mylist),
     function(i)write.csv(mylist[i],
                          file =paste0(names(mylist)[i],'.csv')))
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!