R中的下拉列表实现

发布于 2024-09-16 05:59:47 字数 280 浏览 5 评论 0原文

我正在使用以下代码来开发我一直在开发的股票价格应用程序(非常感谢这里的人们的大量帮助!)。它应该做的事情之一是允许用户选择一家公司来从存储的 XML 文件中进行分析,我一直在使用以下代码来执行此操作:

df <- xmlToDataFrame(file.choose())

而不是使用 file.choose () {显然对话框揭示了很多系统结构},建议使用下拉菜单,其中包含公司列表和文件链接。

这样的事情在 R 中可能吗?有没有一种简单的方法来实现它?

I am using the following code for the Share Price Application I have been developing (with plenty of help from people here that is greatly appreciated!). One of the things it should do is allow the user to pick a company to analyse from stored XML Files, I have been using the following code to do this:

df <- xmlToDataFrame(file.choose())

Instead of using file.choose () {as apparently the dialogue box reveals to much of the system structure}, it has been suggested to use a drop down menu, with a list of the companies and a link to the file.

Is such a thing possible in R and is there an easy-ish way of implementating it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寂寞陪衬 2024-09-23 05:59:47

select.list 允许您从列表中进行选择。另请检查菜单

示例:

使用 menu

companies <- c("AAA","BBB","CCC")
links <- c("c:/file1","c:/secret/file3","c:/file3")

i <- menu(companies, graphics=TRUE, title="Choose company")
df <- xmlToDataFrame(links[i])

使用 select.list

companies <- c("AAA","BBB","CCC")
links <- c("c:/file1","c:/secret/file3","c:/file3")

i <- select.list(companies, title="Choose company")
df <- xmlToDataFrame(links[companies==i])

如果您想在列表上显示名称和链接,请使用

menu_items <- paste(companies, " (", links, ")", sep="")
i <- select.list(menu_items, title="Choose company")
df <- xmlToDataFrame(links[menu_items==i])

select.list allow you to select from a list. Check also menu.

Examples:

Using menu

companies <- c("AAA","BBB","CCC")
links <- c("c:/file1","c:/secret/file3","c:/file3")

i <- menu(companies, graphics=TRUE, title="Choose company")
df <- xmlToDataFrame(links[i])

Using select.list

companies <- c("AAA","BBB","CCC")
links <- c("c:/file1","c:/secret/file3","c:/file3")

i <- select.list(companies, title="Choose company")
df <- xmlToDataFrame(links[companies==i])

If you want to show name and link on list then use

menu_items <- paste(companies, " (", links, ")", sep="")
i <- select.list(menu_items, title="Choose company")
df <- xmlToDataFrame(links[menu_items==i])
只为一人 2024-09-23 05:59:47

如果您不想进行 tcltk 编程,请尝试 gWidgets 软件包。

library(gWidgetstcltk) # or library(gWidgetsRGtk2), etc.
drp <- gdroplist(c("AAA", "BBB", "CCC"), container = gwindow())

If you don't want to get into tcltk programming, try the gWidgets packages.

library(gWidgetstcltk) # or library(gWidgetsRGtk2), etc.
drp <- gdroplist(c("AAA", "BBB", "CCC"), container = gwindow())
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文