populateA <- function(table){
if (table$F[[1]] == "Calendar"){
table$A <- with(table, `End Date` - `Start Date`)
table$A <- as.numeric(table$A)
}else{
Holiday <- read_excel(path)
Holiday_1=as.Date(Holiday$Date,'%Y/%m/%d')
for (i in 1:nrow(table)){
Row <- table[i,]
Start<-as.Date(Row$`Start Date`,'%Y/%m/%d')
End<-as.Date(Row$`End Date`,'%Y/%m/%d')
d <- seq(Start, End, 1)[-1]
table[i,"A"] <- sum(!format(d, "%u") %in% c("6", "7") & !d %in%
Holiday_1)
}
}
return(table)
}
我通过插入i=1
来多次独立运行此代码,但是,当我从代码内部调用它时,会引发错误:
seq.int(0,to0-from,by)中的错误:“ to”必须是有限数