I have .csv files in a directory (lets say C:/Dowloads). I am able to read all the files from that directory using the list.files("path"). But I am unable to read a specified number of files using a for loop. That is, lets say I have 332 files and I just want to read only files 1 to 10 or 5 to 10.
Here is an example:
files <- list.files("path")
files ## displays all the files.
Now for testing I did:
k <- files[1:10]
k
## here it displays the files from 1 to 10.
So I kept the same thing using a for loop, as I want to read files one by one.
for(i in 1:length(k)){
length(i) ## just tested the length
}
But it is giving as NA or Null or 1.
Can any one explain how can I read specified .csv files using a for loop or any other way?