Taking a sample of from a bunch of pictures

Hello,

I want to take a sample of 500 pictures from a folder which contains about 87.000 pictures.
When I use

list.files(path="C:\Users\My Name\Bachelor\images", recursive= TRUE, full.names = TRUE)

it lists me up to 1.000 picture names (which is the max.print size) but when I want to take a sample of those with:

sample("C:\Users\My Name\Bachelor\images\",500,replace=FALSE, prob=NULL)

it gives me following error message: "cannot take a sample larger than the population when 'replace = FALSE'"

So here's my question: How can I make Rstudio take a sample from those mentioned 87.000 pictures?

Thanks in advance

Put the list in an object, and then sample.

x <- list.files(path="C:\Users\My Name\Bachelor\images", recursive= TRUE, full.names = TRUE)
y <- sample(x, 500, replace=FALSE, prob=NULL)
y

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Thank you very much :slight_smile: