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?
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])
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())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With