Prepared by VOLKAN OBAN
Some Examples in R:
Drop-Down Combo Boxes in R.
Example 1-
Example 2-
Example 3
library(shiny)
runApp(list(
ui = bootstrapPage(
numericInput('n', 'Enter 3 for condition', 3, 0, 10),
conditionalPanel(condition="input.n==3",
div(style="display:inline-block",
tags$label('Menu1', `for` = 'Sample'),
tags$select(id = 'Sample', class="input-small",
tagList(mapply(tags$option, value = 1:10,
paste0(letters[1:10], 1:10),
SIMPLIFY=FALSE)))
),
div(style="display:inline-block",
tags$label('Menu2', `for` = 'Sample1'),
tags$select(id = 'Sample1', class="input-small",
tagList(mapply(tags$option, value = 1:2,
paste0(letters[1:2], 1:2),
SIMPLIFY=FALSE)))
)
)
, textOutput("cond")
),
server = function(input, output) {
output$cond <- renderText({
if(input$n == 3){
paste0("Sample value selected =", input$Sample, " Sample1 value selected
=",input$Sample1)
}
})
}
))
Example:
require(tcltk)
tclRequire("BWidget")
tt <- tktoplevel()
tkgrid(tklabel(tt,text="What's your favorite fruit?"))
fruits <- c("Apple","Orange","Banana","Pear")
comboBox <- tkwidget(tt,"ComboBox",editable=FALSE,values=fruits)
tkgrid(comboBox)
OnOK <- function()
{
fruitChoice <- fruits[as.numeric(tclvalue(tkcmd(comboBox,"getvalue")))+1]
tkdestroy(tt)
msg <- paste("Good choice! ",fruitChoice,"s are delicious!",sep="")
tkmessageBox(title="Fruit Choice",message=msg)
}
OK.but <-tkbutton(tt,text=" OK ",command=OnOK)
tkgrid(OK.but)
tkfocus(tt)
EXAMPLE:
dygraphs
> library(dygraphs)
> lungDeaths <- cbind(mdeaths, fdeaths)
> dygraph(lungDeaths)
e
Example: Shiny Dashboard.
library(shiny)
library(shinydashboard)
Ref: https://rstudio.github.io/shinydashboard/structure.html
Reference and codes: shiny.rstudio.com/gallery/
Example:
Reference and codes: http://shiny.rstudio.com/gallery/datatables-
demo.html
Reference:
• http://stackoverflow.com/questions/3574114/drop-down-list-implementation-in-r
• http://shiny.rstudio.com/gallery/select-box.html
• http://mcu.edu.tw/~chenmh/teaching/project/r/reference/RTclTkExamples/DropDown.html
• http://shiny.rstudio.com/gallery/

Some Examples in R.