我以This link为参考
我原来的方法是:
DATA <- NULL
n <- length(list.files())
for (i in 1:n){
wb <- loadWorkbook(list.files()[i])
ws <- readWorksheet(wb,
sheet=getSheets(wb), header=TRUE, startRow=3, endCol=45)
ws$Issue.Date <- as.Date(substr(ws$Issue.Date, 1, 10)) #i need to standardize the date format.
ws$Flt.Date <- as.Date(substr(ws$Flt.Date, 1, 10))
ws$Dnl.Date <- as.Date(substr(ws$Dnl.Date, 1, 10))
ws$Ver.On <- as.Date(substr(ws$Ver.On, 1, 10))
DATA <- rbind(DATA, ws)
}
虽然从链接中,它提到了do.call(rbind,...),所以我尝试了:
> DATA2 <- do.call(rbind, lapply(list.files(), function(x) {
+ wb <- loadWorkbook(x)
+ ws <- readWorksheet(wb,
+ sheet=getSheets(wb), header=TRUE, startRow=3, endCol=45)
+ ws$Issue.Date <- as.Date(substr(ws$Issue.Date, 1, 10))
+ ws$Flt.Date <- as.Date(substr(ws$Flt.Date, 1, 10))
+ ws$Dnl.Date <- as.Date(substr(ws$Dnl.Date, 1, 10))
+ ws$Ver.On <- as.Date(substr(ws$Ver.On, 1, 10))
+ }))
Warning message:
In (function (..., deparse.level = 1) :
number of columns of result is not a multiple of vector length (arg 1)
谢谢!