使用Shiny创建应用程序来绘制CSV文件

问题描述 投票:0回答:1

i已预先载入到被称为投资者的环境中,并有一个名为marital_status的专栏。
这是我尝试发布应用程序时遇到的错误:`该应用程序无法启动:

exited unexpectedly with code 1 Loading required package: ggplot2 Attaching package: ‘plotly’ The following object is masked from ‘package:ggplot2’: last_plot The following object is masked from ‘package:stats’: filter The following object is masked from ‘package:graphics’: layout Attaching package: ‘dplyr’ The following objects are masked from ‘package:stats’: filter, lag The following objects are masked from ‘package:base’: intersect, setdiff, setequal, union Attaching package: ‘DT’ The following objects are masked from ‘package:shiny’: dataTableOutput, renderDataTable Error in value[[3L]](cond) : object 'fig' not found Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous> Execution halted

如果您希望情节成为您的输出,则需要记住以下内容:
r ggplot2 shiny plotly
1个回答
1
投票
服务器:

output$fig <- renderPlotly

而不是
    output$fig <- renderPlot
  1. UI:
    mainPanel(plotlyOutput("fig"))
    而不是
    mainPanel(fig))
  2. 您不必将绘图分配给对象,只需在末端留下
    ggplotly(p)
    
    您可以尝试此代码以查看其工作原理:
  3. library(shiny) library(ggplot2) library(ggthemes) library(plotly) ui <- fluidPage( titlePanel("Plotly"), sidebarLayout( sidebarPanel(), mainPanel( plotlyOutput("plot2")) )) server <- function(input, output) { output$plot2 <- renderPlotly({ ggplotly( ggplot(data = mtcars, aes(x = disp, y = cyl)) + geom_smooth(method = lm, formula = y~x) + geom_point() + theme_gdocs()) }) } shinyApp(ui, server)
        
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.