我想读取一个包含多张工作表的 excel 文件并为每张工作表指定 col_types,以下是我的代码:
data_file <- "./input/data.xlsx"
sheet_names <- c("Sales", "Customs", "Departments")
col_type_list <- list(
Sales = c(rep("text", 3), rep("numeric", 2)),
Customs = rep("text", 5),
Departments = rep("text", 4)
)
DList <- purrr::map2(.x = sheet_names, .y = col_type_list,
.f = read_xlsx(
path = data_file,
sheet = .x,
col_types = .y
)
)
执行上面的代码,得到如下错误信息:
Error in standardise_sheet(sheet, range, sheets_fun(path)) :
object '.x' not found
如何将正确的 .x 和 .y 放入代码中?