对象“输入”未找到并对象“输出”;在 R Shiny 应用程序中找不到
我正在尝试在 R 中的 Shiny App 中创建散点图,但我不断收到无法找到我的输入和输出的错误消息。我已经尝试了所有我能想到的可能导致这些问题的方法,但到目前为止尚未解决。我真的很感激一些帮助。我的代码如下:
我的 UI:
shinyUI(fluidPage(
titlePanel("Scatterplot Basketball Statistics"),
sidebarPanel(
selectInput(inputId = "x",
label = "Select variable to plot",
choices = names(dt.basketball),
selected = "Season"),
selectInput(inputId = "y",
label = "Select variable to plot against",
choices = names(dt.basketball),
selected = "3PA"),
#Output: Show the output of the scatter plot
mainPanel(
plotOutput(outputId = "scatterplot")
))
)
)
和我的服务器:
library(ggplot2)
library(shiny)
shinyServer(function(input,output){
output$scatterplot <- renderPlot({
ggplot(data = dt.basketball, aes_string(input$x, input$y) + geom_point())
})
})
我收到的错误消息如下:
Error in output$scatterplot <- renderPlot({ : object 'output' not found
和
Error in aes_string(input$x, input$y) : object 'input' not found
I'm trying to create a scatter plot in Shiny App in R, but I keep getting the error messages that my input and output can not be found. I've tried all the things I could think of that could be causing these issues, but as of yet it is unresolved. I'd really appreciate some help. My code is the following:
My UI:
shinyUI(fluidPage(
titlePanel("Scatterplot Basketball Statistics"),
sidebarPanel(
selectInput(inputId = "x",
label = "Select variable to plot",
choices = names(dt.basketball),
selected = "Season"),
selectInput(inputId = "y",
label = "Select variable to plot against",
choices = names(dt.basketball),
selected = "3PA"),
#Output: Show the output of the scatter plot
mainPanel(
plotOutput(outputId = "scatterplot")
))
)
)
And my server:
library(ggplot2)
library(shiny)
shinyServer(function(input,output){
output$scatterplot <- renderPlot({
ggplot(data = dt.basketball, aes_string(input$x, input$y) + geom_point())
})
})
The error messages I get are the following:
Error in output$scatterplot <- renderPlot({ : object 'output' not found
and
Error in aes_string(input$x, input$y) : object 'input' not found
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论