Error in File(File, "Rt"):Cannot Open the Connection

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

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)

Error in file(file, rt) : cannot open the connection in r even after setting right path

The error is because the path is wrong: you forgot the trailing slash in the path prefix in str_c. However, rather than using str_c, you can instruct list.files to give you full paths from the get-go:

files <- list.files(
path = "C:/Users/91932/Downloads/archive (2)/Fitabase Data 4.12.16-5.12.16",
pattern = ".csv",
full.names = TRUE
)


Related Topics



Leave a reply



Submit