File browser in R

2020-02-08 07:50发布

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)?

标签: file r
3条回答
等我变得足够好
2楼-- · 2020-02-08 08:11

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.

查看更多
冷血范
3楼-- · 2020-02-08 08:23

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).

查看更多
走好不送
4楼-- · 2020-02-08 08:25

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.

查看更多
登录 后发表回答