Reputation: 23
I want to load more than one image with load.image() function provided in "imager" package, but i have got an Error with "File not found" message. Could someone please help me in this problem?
I've tried to load the images in the list, and add this list as a parameter to the load.image() function, but it can only read one file, so the list is not acceptable. After this i tried to iterate in the list with a for loop, and add the index from the loop as the parameter, and i've got this problem: "Error in wrap.url(file, load.image.internal) : File not found"
filenames <- list.files("~/Downloads/project", pattern="*.JPG")
for(idx in filenames) {
load.image(idx)
"I tried here with concatenate the idx with the path string, but with no success"
load.image(paste("~/Downloads/project",idx))
}
Upvotes: 2
Views: 3017
Reputation: 9313
Try adding full.names = T
option to the list.files
. This adds the full path to the file, if not present only the file name is returned.
list.files("~/Downloads/project", pattern="*.JPG", full.names = T)
then just load.image(idx)
in your loop
Upvotes: 2