【发布时间】:2016-01-20 13:44:16
【问题描述】:
我有两个问题要解决。首先,模型没有运行我不知道为什么?
DONE!,作者:Vongo 和 Nice。第一个问题是:我有两个位置,它们的销售数量显示为情节。我想根据像 ggtitle("Analyze of input$location") 这样的选择输入来更改绘图标题。
其次,我想在侧边栏面板中显示绘图 - 在执行按钮下方 -。然而,在练习中,我有一个白色的空白区域,已经预订了要制作的地块。在执行情节之前,我不想在侧边栏面板中有这个预订区域。
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))呢? (可能是我读得太快了) -
是的,谢谢!