Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
I';我在尝试将多张XLS图纸导出到其中时遇到问题';s在R中拥有自己的csv文件_R - Fatal编程技术网

I';我在尝试将多张XLS图纸导出到其中时遇到问题';s在R中拥有自己的csv文件

I';我在尝试将多张XLS图纸导出到其中时遇到问题';s在R中拥有自己的csv文件,r,R,我对R有点陌生,我只是不知道怎么做。我有一个函数,可以打开一个XLS文件,并将其转换为一个数据帧列表-每个数据帧都是它自己的数据帧。现在我想为每张图纸将这些文件导出到不同的CSV文件中。这是我的密码: preberiXLS<- function(potDoXLS,tibble = FALSE){ tryCatch(expr = {path1=potDoXLS excel_sheets(path1)},error=function(e){print "Inp

我对R有点陌生,我只是不知道怎么做。我有一个函数,可以打开一个XLS文件,并将其转换为一个数据帧列表-每个数据帧都是它自己的数据帧。现在我想为每张图纸将这些文件导出到不同的CSV文件中。这是我的密码:

preberiXLS<- function(potDoXLS,tibble = FALSE){
  
  tryCatch(expr = {path1=potDoXLS
  excel_sheets(path1)},error=function(e){print 
    "Input mora biti excelova datoteka"})
  
  sheets <- readxl::excel_sheets(potDoXLS)
  x <- lapply(sheets, function(X) readxl::read_excel(potDoXLS, sheet = X))
  if(!tibble) x <- lapply(x, as.data.frame)

  names(x) <- gsub("[^[:alpha:]]", "", sheets)
  
 
  write.csv(x,paste0("HW3Data/",names(x),".csv"))

  x

 
  
}
preberiXLS您可以尝试:

preberiXLS<- function(potDoXLS){
  
  tryCatch(expr = {path1=potDoXLS
  excel_sheets(path1)},error=function(e){print 
    "Input mora biti excelova datoteka"})
  
  sheets <- readxl::excel_sheets(potDoXLS)
  lapply(sheets, function(X) {
    write.csv(readxl::read_excel(potDoXLS, sheet = X), 
              paste0(X, ".csv"), row.names = FALSE)
  })
}

preberixls感谢您的帮助。。当我读到你的解决方案时,我感到很傻。。当然,我的代码不起作用,我只是以csv格式编写了第一张工作表,并没有将其应用于所有工作表。