ui.R
library(shiny)
shinyUI(pageWithSidebar(
# Application title
headerPanel("New Application"),
# Sidebar with a slider input for number of observations
sidebarPanel(
sliderInput("obs",
"Number of observations:",
min = 1,
max = 90,
value = 10)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
))
server.R
library(shiny)
library(RMySQL)
con<-dbConnect(MySQL(),group="kettle")
mydata<-dbReadTable(con,"sellStatic")
mydata
myvars<-c("goodsID","goodsName","sellCount")
newdata<-mydata[myvars]
myvars
goodsName<-newdata$goodsName
sellCount<-newdata$sellCount
goodsName
sellCount
mydata<-data.frame(goodsName,sellCount)
shinyServer(function(input, output) {
output$distPlot <- renderPlot({
# generate and plot an rnorm distribution with the requested
# number of observations
newdata<-mydata[1:input$obs,]
barplot(newdata$sellCount,names.arg=newdata$goodsName)
})
})