[R] R user interface
jverzani
jverzani at gmail.com
Thu Jun 17 18:57:59 CEST 2010
Shubha Vishwanath Karanth <shubhak <at> ambaresearch.com> writes:
>
> Hi R,
>
> I have a an excel file with a lot of data. I need to create an user
> interface in R, which has one single screen. It needs to contain a right
> pane containing the click buttons for different countries (say). If the
> user clicks a country, then a chart needs to be created for that
> country, taking the data from Excel. Is this possible and which package
> helps me in doing this? Many thanks in advance.
>
> Thanks and Regards,
>
If you don't mind installing the GTK libraries, then the traitr package can be
used here without too much difficulty. Here is what you can do for your request
(a stripped down version of a demo in the vignette)
## sample data, replace me
d <- data.frame(country=c("US","US","Canada","Mexico"),
x = rnorm(1:4),
y = rnorm(1:4))
library(traitr)
library(gWidgets) ## also gWidgetsRGtk2, cairoDevice
options(guiToolkit="RGtk2")
countries <- unique(d$country)
dlg <- aDialog(items=list(
output=graphicDeviceItem(),
countryFilter=choiceItem(value=countries, values=countries,
multiple=TRUE, show_label=FALSE)
),
help_string="Use filter to narrow",
## this is called when the countryFilter checkbox is clicked
property_countryFilter_value_changed=function(.,...)
.$make_plot(),
## this draws the plot
make_plot=function(.) {
countries <- .$get_countryFilter()
## adapt this:
plot(y ~ x, data=d, subset=country %in% countries)
})
view <- aPanedGroup(aContainer("output"),
aFrame(label="Filter by:",
aFrame("countryFilter", label="Country")),
horizontal=TRUE
)
dlg$make_gui(gui_layout=view)
dlg$make_plot()
> Shubha Karanth
>
> This e-mail may contain confidential and/or privileged i...{{dropped:13}}
>
>
More information about the R-help
mailing list