【发布时间】:2017-10-16 07:21:38
【问题描述】:
得到错误:
output object not found
不知道为什么会这样,我在过去的仪表板上做过同样的事情,当时没有发生错误。 指定了输出对象,但仍然无法检测到
Server.R
d <-read_excel("data/ds.xlsx",sheet = 1)
output$plot1 <- renderPlotly({
data <- switch(input$var,
"Beginning Stocks (1000 MT)"= d$`Beginning Stocks (1000 MT)`
,"Area Harvested (1000 HA)" = d$`Area Harvested (1000 HA)`
,"Yield (MT/HA)" = d$`Yield (MT/HA)`
,"Production (1000 MT)" = d$`Production (1000 MT)`
,"MY Imports (1000 MT)" =d$`MY Imports (1000 MT)`
)
data1 <- switch(input$var1,
"Beginning Stocks (1000 MT)"= d$`Beginning Stocks (1000
MT)`
,"Area Harvested (1000 HA)" = d$`Area Harvested (1000 HA)`
,"Yield (MT/HA)" = d$`Yield (MT/HA)`
,"Production (1000 MT)" = d$`Production (1000 MT)`
,"MY Imports (1000 MT)" =d$`MY Imports (1000 MT)`
)
plot_ly(d, x =~d$`Attributes (Unit)`, y = ~data,type= "scatter",mode =
'markers+lines', marker = list(size = 10),name=input$var) %>%
add_trace(x = ~d$`Attributes (Unit)`, y = ~data1,type="scatter"
,mode="markers+lines",name=input$var1)
})
UI.R
navbarPage("Barley Dashboard",
tabPanel("Balance sheet",
fluidPage(theme = shinytheme("united"),
mainPanel(fluidRow( column(8,selectInput("var",selected="select",
label = "Choose first variable",
choices = c( "Beginning Stocks (1000 MT)","Area Harvested (1000
HA)","Yield (MT/HA)","Production (1000 MT)","MY Imports (1000
MT)")
)
),
column(8,selectInput("var1", selected = "select",
label = "Choose second variable",choices = c("Beginning Stocks
(1000 MT)", "Area Harvested (1000 HA)","Yield (MT/HA)","Production
(1000 MT)","MY Imports (1000 MT)")
)
)
),
plotlyOutput("plot1")
) ) ) )
出现错误:Error in output$plot1 <- renderPlotly({ : object 'output' not found
我无法纠正错误
【问题讨论】:
-
你有
server <- function(input, output, session){ -
@akrun no 我为 ui 和 server 创建了单独的选项卡,所以不包括这个
-
你的例子不可复现,所以其他人无法在他们的机器上尝试
-
我已经复制了这个例子。现在的问题是你没有在任何地方初始化你的
d数据框......所以仍然有错误 -
现在我已经添加了数据,你现在可以试试吗@AntoinePissoort