ui.r
這主要是爲每天銷售商店如何從ui.r傳遞多個可變閃亮應用server.r在反應性方式
shinyUI(fluidPage(
titlePanel("Sales Analysis"),
sidebarLayout(
sidebarPanel(
helpText("Create line graph for
Sale."),
selectInput(multiple='TRUE' ,"var",
label = "Choose a year to display",
choices = c(Result),
selected = "Result[1]",
selectInput("var2",
label1 = "Choose a month to display",
choices1 = c(Result2),
selected1 = "Result2[1]")),
mainPanel(
plotOutput("lineplot"),
print(Result),
print(Result1)
)
)
))
的數據分析server.r
這主要是針對使用閃亮的web應用程序的商店的每天銷售數據分析 ,所以我想要的是什麼是在ui.r中有多個下拉框,要選擇一個下拉根據其他下拉選擇,然後將這些選中的下拉變量傳遞給server.r,它應該是pa在查詢中被視爲被動方式。
library(shiny)library for shiny web browser
library(DBI) database package
library(rJava)for connection basic package
library(RJDBC)
library(scales)
library(ggplot2)
library(PKI)
library(RCurl)
library(rsconnect)
shinyServer(function(input, output) {
output$lineplot <- renderPlot({
jcc = JDBC("","")
conn = dbConnect(jcc,"//",user="",
password="")
Result<-dbGetQuery(conn,statement = paste("select sale_dt,count(trd) as Bill from retail_str_sales_master where year(sale_date)=",input$var," group by sale_date"))
Result$SALE_DATE<-as.Date(Result$SALE_Dt)
#Result1<-dbGetQuery(conn,statement = paste("select sale_dt,count(trd) as Bill from retail_str_sales_master where to_char(to_date(month(sale_date),'MM'),'Month')=",input$var," group by sale_date"))
draw the line Graph with the specified number of bins using Sale date and Total no Of Bills
ggplot(Result,aes(x=SALE_DATE,y=BILL))+geom_line()+geom_point()+scale_x_date(date_breaks ="2 day", date_labels=("%d-%m-%y"))+
scale_y_continuous(breaks =seq (0,max(Result$BILL),200))+ylab("Total No Of Bills")+xlab("sale date")+theme_bw()+
theme(axis.text.x=element_text(angle=90))+theme(axis.text.x = element_text(vjust = 0.5,hjust = 0.5))
})
})
問題是我已經使用查詢來獲取UI部分中的值。對於單一年的價值,圖形出來good.But因爲我需要選擇基於年的月份,然後將值傳遞給服務器在查詢,這是事情不起作用的地方我不能在查詢中的條件中傳遞兩個變量來使圖動態化。 – Manish