r - file.choose()自定义对话窗口 [英] r - file.choose() customizing dialogue window

查看:835
本文介绍了r - file.choose()自定义对话窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 file.choose()之后弹出的对话窗口是否有办法显示自定义标题,类似于 X < - menu(files,graphics = TRUE,title =选择文件X)

Is there a way for the dialogue window that pops up after file.choose() is run to display a custom title, similar to X <- menu(files, graphics=TRUE, title="Choose file X")?

现在我的代码需要几个文件已加载。

Right now my code requires several files be loaded.

X <- read.csv(file.choose())
Y <- read.csv(file.choose())
Z <- read.csv(file.choose())

目前我只是使用我的(人类)内存来知道为第一个窗口,第二个窗口和第三个窗口选择哪些文件,但是我希望窗口显示哪个对象 X Y Z 当前窗口的文件将导入到。我可以将窗口移到一边看看控制台的代码行,但这看起来非常不优雅。

At the moment I'm just using my (human) memory to know which files to choose for the first window, the second window, and the third window, but I'd like the window to show which object X Y or Z the current window's file will be imported to. I can move the window aside to see which line of code the console is up to, but that seems pretty inelegant.

我试过 X < - read.csv(file.choose(new = c(Choose X))))例如但似乎没有做任何事情。

I've tried X <- read.csv(file.choose(new=c("Choose X"))) for example but that doesn't seem to do anything.

推荐答案

替代方案:

library(tcltk)
X <- read.csv(tk_choose.files(caption = "Choose X"))

看到该功能也可用于在一次通话中选择多个文件。为此,在选择多个文件时按住CTRL键:

See that the function can also be used to select multiple files in one call. For that, hold CTRL when selecting more than one file:

XYZ.list <- lapply(tk_choose.files(caption = "Choose X, Y, and Z"), read.csv)

但选择顺序不是保留,这样你可能想要保持三个单独的电话,如果这对你更好。

but the selection order is not preserved so you might want to keep three separate calls if that works better for you.

这篇关于r - file.choose()自定义对话窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆