Drop-down list in R

I use the following code for the stock price app I was developing (with a lot of help from people who are very much appreciated!). One of the things he has to do is let the user choose a company to analyze from the stored XML files, for this I used the following code:

df <- xmlToDataFrame(file.choose())

Instead of using file.choose () {as you can see, the dialog box shows most of the structure of the system}, it was suggested to use a drop-down menu with a list of companies and a link to the file.

Is this possible in R and is there a simple way to implement it?

+5
source share
2 answers

select.listallows you to choose from a list. Also check out 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])

,

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

tcltk, gWidgets.

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

All Articles