Arguments in read.delim when used in lapply

萝らか妹 提交于 2019-12-08 08:06:21

问题


I'm using the following code to read a set of CSV files:

csvfiles = list.files(pattern = "*.csv", path = "./Data/", 
                      full.names = TRUE)
## Merge into one object
myfiles = lapply(csvfiles, read.delim)

I would like to pass some arguments to the read.delim function in order to skip a set of initial rows, define delimiter and so on but whenever I try doing this R returns an error, as illustrated below:

> myfiles = lapply(csvfiles, read.delim(skip = 2))
Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
  argument "file" is missing, with no default

What would the correct syntax to modify the parameters of the read.delim function when used in conjunction with the lapply, as illustrated above?

来源:https://stackoverflow.com/questions/25958505/arguments-in-read-delim-when-used-in-lapply

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!