Selecting multiple files with file.choose() on a MacBookAir not working

Viewed 210

I am running the package 'pophelper' in RStudio on a MacBookAir where I need to choose multiple files using file.choose(). However, when the interactive window pops up I can only highlight one file and not choose multiple files with the 'Shift' key. I've tried the 'control', 'option', 'command' key and any combination thereof but only managed to highlight one file at a time. I have to choose dozens of files so doing it one by one is not an option. Has anybody else encountered this issue and is there a solution to it?

Thanks for your help

1 Answers

From this question file.choose for multiple files R, you can use tk_choose.files() in tcltk package to choose a list of files interactively.


In addition, you can also make a custom function with select.list() and set multiple = T and graphics = T to call a graphical widget and select more than one item.

file.choose2 <- function(path = "."){
  file <- dir(path)
  select <- select.list(file, multiple = T, graphics = T)
  return(file.path(path, select))
}

file.choose2("path/to/your/files")

The drawback of this function is that you can only select those files in the given path.

Related