heres the reproducible example:
library(shiny)
library(DT)
library(RODBC)
library(shinythemes)
library(shinydashboard)
library(ggplot2)
ui=navbarPage(theme=shinytheme("sandstone"),title=h6("App Tienda V2"),
tabPanel(
("Consulta"),
sidebarPanel(
textInput("Tienda","Tienda"),
textInput("depto","depto"),
textInput("Articulo","Articulo"),
actionButton("mybutton","Consultar Tienda")
),
mainPanel(
plotOutput("scat")
),
DT::dataTableOutput("tableDT1")
),
tabPanel(("DETALLE"),
DT::dataTableOutput("tableDT")),
tabPanel(("text"),
fluidPage(
fluidRow(
column(2,box(verbatimTextOutput("Store_Nbr"), status = "primary", solidHeader = FALSE, collapsible = FALSE, width = 9, title = "DET")),
column(2,box(verbatimTextOutput("Store_Name"), status = "primary", solidHeader = TRUE, collapsible = FALSE, width = 9, title = "TIENDA")),
column(2,box(verbatimTextOutput("Old_Nbr"), status = "primary", solidHeader = TRUE, collapsible = FALSE, width = 9, title = "ARTICULO"))
),
fluidRow(
column(2,box(verbatimTextOutput("UPC"), status = "primary", solidHeader = FALSE, collapsible = FALSE, width = 9, title = "DET")),
column(2,box(verbatimTextOutput("Dept_Nbr"), status = "primary", solidHeader = TRUE, collapsible = FALSE, width = 9, title = "TIENDA")),
column(2,box(verbatimTextOutput("Category_Nbr"), status = "primary", solidHeader = TRUE, collapsible = FALSE, width = 9, title = "ARTICULO"))
)
)
))
server=function(input,output,session){
origTable_selected <- reactive({
ids <- input$tableDT1_rows_selected
})
output$Store_Nbr=renderText({mtcars[origTable_selected(),1]})
output$Store_Name=renderText({toString(mtcars[origTable_selected(),2])})
output$Old_Nbr=renderText({mtcars[origTable_selected(),3]})
output$UPC=renderText({mtcars[origTable_selected(),4]})
output$Dept_Nbr=renderText({mtcars[origTable_selected(),5]})
output$tableDT1=DT::renderDataTable(mtcars[1:nrow(mtcars),],
options=list(paging=T),
rownames=F,
filter="top",
selection="single")
plotData=reactive({
wks=c("Current","Wk1","Wk2","Wk3")
vtas=c(mtcars[origTable_selected(),1],mtcars[origTable_selected(),2],mtcars[origTable_selected(),3],
mtcars[origTable_selected(),4])
fcst=c(mtcars[origTable_selected(),5],mtcars[origTable_selected(),6],mtcars[origTable_selected(),7],
mtcars[origTable_selected(),8])
dats=data.frame(wks,vtas,fcst)
colnames(dats) <- c("Weeks","Vtas4", "Fcst4")
return(dats)
})
output$scat=renderPlot({
ggplot(plotData())+
geom_point(aes(x=Weeks,y=Vtas4,color='blah',size=2))+
geom_line(aes(x=Weeks,y=Vtas4,color="blah1"))+
#redplot
geom_point(aes(x=Weeks,y=Fcst4,color='blahx',size=2))+
geom_line(aes(x=Weeks,y=Fcst4,color="blahx1"))+
scale_color_manual(values=c('blah'='blue','blah1'='blue','blahx'='red','blahx1'='red'))
})
}
shinyApp(ui=ui,server=server)
thanks a lot