I have multiple directories within one common directory and each containing a CSV file (and some other files too).
I want to read all the CSV files using FOR loop in R. The name of each directory (within the common directory) are not in sequence however the name of each CSV file within the directory is the same as the directory it is in. I wrote the following simple code but it gives me error.
files <- c(21,22,29,30,34,65,66,69,70,74)
for(i in files) { # Loop over character vector
F[i] <- read.csv("F:/Fish[i]/Fish[i].csv")
}
Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file '/Fish[i]/Fish[i].csv': No such file or directory
Any help where I am making mistake here?
Thank you