Getting error in file(file, “rt”): cannot open the connection

前端 未结 4 746
滥情空心
滥情空心 2021-01-22 14:04

I am running the following code...

#Create a list of all the files
file.list <- list.files(path=\"~/R/natural-language-processing/class-notes\", pattern=\".cs         


        
4条回答
  •  心在旅途
    2021-01-22 14:37

    Most likely you are trying to open files from the working directory instead of the directory in which you called list.files. Instead try

    D1 <- do.call("rbind",
                  lapply(paste0("~/R/natural-language-processing/class-notes/",
                                file.list),
                         read.csv, header = TRUE, stringsAsFactors = FALSE))
    

    Alternatively, you can set the full.names argument to TRUE in list.files to get complete paths:

    file.list <- list.files(path="~/R/natural-language-processing/class-notes", 
                            pattern=".csv", full.names = TRUE)
    

提交回复
热议问题