excel 文件.exists(路径)中出错:R中“file”参数无效

wvt8vs2t  于 2023-03-09  发布在  其他
关注(0)|答案(1)|浏览(244)

请接受我的道歉,因为我是R的新手。下面的代码用于一次性处理多个文件,并将输出放在一个单独的文件夹中。

require(highfrequency)
 require(quantmod)
 require(readxl)
 input_files1=list("file_path1.xlsx","file_path2.xlsx","file_path3.xlsx")    #making list of file paths

for(i in length(input_files1))

{
    bid_df<-read_excel(input_files1[i], sheet = 1, col_names = TRUE, col_types = NULL, na = "", skip = 0)
#read_excel takes file path as first argument
    ask_df<-read_excel(input_files1[i], sheet = 2, col_names = TRUE, col_types = NULL, na = "", skip = 0)

    trade_df<-read_excel(input_files1[i], sheet = 3, col_names = TRUE, col_types = NULL, na = "", skip = 0)

  qdata_df <- merge(ask_df, bid_df, by = "TIMESTAMP")
  qdata_xts_raw<-xts(qdata_df[,-1], order.by=qdata_df[,1])
  qdata_xts_m<-mergeQuotesSameTimestamp(qdata_xts_raw, selection = "median")
  trade_xts_raw <- xts(trade_df[,-1], order.by=trade_df[,1])
  trade_xts_m<-mergeTradesSameTimestamp(trade_xts_raw, selection = "median")
  tqdata=matchTradesQuotes(trade_xts_m,qdata_xts_m)
  quoted_spread<-tqLiquidity(tqdata,trade_xts_m,qdata_xts_m,type="qs")
  qs_30<-aggregatets(quoted_spread,FUN="mean",on="minutes",k=30)
  indexTZ(qs_30) <- "UTC"

  write.csv(qs_30, file = file.path("output_file_path", paste0("CAN_out",    i)))
  }

当代码运行时,它给出以下错误Error in file.exists(path):“file”参数无效请帮助删 debugging 误并运行代码。

相关问题