may*_*k14 3 r shiny shiny-server shinydashboard
我正在尝试为我使用闪亮生成的输出添加图形。我在生成图形时出错。有人可以看看并提供帮助。条形图参数是根据计算生成的基于计算的输出。
server
output$graph<- renderPlotly({
plotly( x= c(as.numeric(input$contract), round(frateperton()), differencerate()),
y= c('Contract Rate', 'ZBC Rate', 'Difference'),
name = "Zero Based Rate Chart",
type = "bar")
})
UI
plotlyOutput("graph"),
Run Code Online (Sandbox Code Playgroud)
bre*_*auv 14
首先,对你的帖子有两点评论:
下次遇到问题,请考虑这两点,然后再在 StackOverflow 上发帖。
现在,这是答案(使用iris数据,因为您的示例不可重现):
library(shiny)
library(plotly)
ui <- fluidPage(
selectInput("choice", "Choose", choices = names(iris), selected = NULL),
plotlyOutput("graph")
)
server <- function(input, output, session){
output$graph <- renderPlotly({
plot_ly(iris, x = ~get(input$choice), y = ~Sepal.Length, type = 'scatter', mode = 'markers')
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)