我有兩個問題需要解決。首先,模型不運行,我不知道爲什麼?如何在sidebarPanel中顯示沒有空白區域的情節?
DONE!by Vongo and NicE。第一個問題是:我有兩個地點和他們的銷售數量顯示爲情節。我想根據ggtitle(「分析輸入$位置」)等選擇輸入來更改劇情標題。
其次,我想顯示在sidebarPanel中的圖 - 在執行buton-下面。然而,在演習中,我有一個白色的空白區域,已經預定了要製作的地塊。在執行繪圖之前,我不希望在sidebarPanel中有這個預訂區域。
ui.r
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("Sidebar Study"),
sidebarPanel(
selectInput(inputId = "location",label = "Choose Location",
choices = c('Los Angeles', 'New York', selected = "Los Angeles"),
actionButton("execute","Execute")
plotOutput("plot"))),
mainPanel()))
server.r
library(shiny)
shinyServer(function(input, output,session) {
output$plot <- renderPlot({
if(input$execute){
if(input$location="New York"){
tmp <- data.frame(time = 1:100, sales = round(runif(100, 150, 879)))
}
if(input$location="Los Angeles"){
tmp <- data.frame(time = 1:100, sales = round(runif(100, 90, 512))) }
y<-ggplot(as.data.frame(tmp), aes(time)) + geom_line(size=1,aes(y=sales, colour = "sales"))+ ggtitle(paste("Analyze of", input$location))
y
}})
})
對於你的第一個問題,我只是讀得很快,但是'ggtitle(paste(「Analyze of」,input $ location))''呢? (也許我讀得太快) – Vongo
是的,你是對的謝謝! –