1

I want to analyse my images that I store as follow:

jpeg <- list.files(folder)

and I obtain this: enter image description here

As observed R stores picture_1, picture_10, picture_11..., picture_2, etc. So when I analyse I do not know which picture it is.

I would like to store in order to have: picture_1, picture_2.... and be able to perform my analyse.

How to do it ?

Laurent
  • 419
  • 4
  • 14

2 Answers2

2
x = c("picture_1", "picture_10", "picture_11", "picture_2")
x[order(as.numeric(gsub("picture_", "", x)))]
#[1] "picture_1"  "picture_2"  "picture_10" "picture_11"
d.b
  • 32,245
  • 6
  • 36
  • 77
0

How about this:> ?system

system invokes the OS command specified by command.

picture_name <- try(system("ls -Fv folder", intern = TRUE))

#[1] "slice_1.jpg"  "slice_2.jpg"  "slice_3.jpg"  "slice_10.jpg" "slice_11.jpg"
#[6] "slice_20.jpg" "slice_30.jpg"
deepseefan
  • 3,701
  • 3
  • 18
  • 31