Sacha Epskamp
Sacha Epskamp

Reputation: 47541

File browser in R

I need to write a small R script for people who never used R before that imports a file and does some things with it. I would like to minimize user input as much as possible, and since assigning the file-path is basically all the user input required I was wondering, is it possible to get a popup screen (basically your usual "open file" screen) allowing someone to select a file (import the name as string in R or something)?

Upvotes: 26

Views: 27750

Answers (3)

Craig
Craig

Reputation: 4682

It's worth mentioning rChoiceDialogs::rchoose.files. I'm not completely sold yet, but they advertise it as being completely cross platform and fixing the annoying problem common to choose.files and tk_choose.files of popping up behind other windows. See their vignette here.

Upvotes: 3

Spacedman
Spacedman

Reputation: 94172

The tcltk package gives you tk_choose.files.

If you want to go beyond file choosers then you can use the package to build user interfaces.

Upvotes: 3

James
James

Reputation: 66834

The file.choose function performs this, eg:

fname <- file.choose()

source(file.choose())

You may also want to look at choose.files (for multiple files) and choose.dir (for just selecting a directory path).

Upvotes: 41

Related Questions