首页 > 解决方案 > ggplot图在R Shiny Dashboard中不可见

问题描述

server <- function(input, output) {


      output$plot1<-renderPlot({

        if(input$univariate=="Age")
        {

          hist(bankchurn$Age,xlab='Age',ylab='No of Customers',col= '#45b3e0' ,main="Age")


          output$text1<-renderText("hi")`enter code here`

        }

     if(input$univariate=="Gender")
        {
          ggplot(data = bankchurn) +
            aes(x = Gender, fill = Gender) +
            geom_bar() +
            scale_fill_viridis_d(option  = "plasma") +
            theme_minimal()
          output$text1<-renderText("Gender")


        }

在上面的代码中,我的第一个“if”语句正在渲染绘图,但我的第二个使用 ggplot 图的 if 语句没有在仪表板中渲染任何内容。知道如何在这种情况下显示 ggplot 图。

注意:我已经尝试将图形存储在一个变量中,但它仍然没有显示在仪表板中。

标签: rggplot2shinyshinydashboard

解决方案


请您提供一个带有 UI 元素的可重现示例,以便我们进一步评估需要更改的内容


推荐阅读