簡體   English   中英

如何在閃亮的儀表板上使用dplyr制作條形圖

[英]How to make bar plot with dplyr in shiny dashboard

我正在嘗試在閃亮的儀表板的renderUI中繪制條形圖。 以下是我的代碼

output$city_plot <- renderUI({

clean_data(data) %>% 
  group_by(registrant_city) %>%
  summarise(Total= n()) %>% 
  arrange(desc(Total)) %>% 
  ggplot(data=clean_data(data),aes(x= registrant_city, y = Total)) + 
  geom_bar(aes(fill= registrant_city), position = "dodge", stat = "identity") 


})

clean_data是一個在清理和整理數據幀之后返回數據幀的函數

每當我運行有光澤的應用程序時,都會出現Error:Mapping should be created with aes()或aes_() Error:Mapping should be created with 。`我不知道這到底意味着什么。 當我在R控制台中運行相同的代碼時,它為我提供了適當的輸入量。

data%>%
  group_by(registrant_city) %>%
  summarise(Total = n())    %>%
  arrange(desc(Total))      %>%
  top_n(n = 10)             %>%
  ggplot(aes(x= registrant_city, y = Total)) + 
  geom_bar(aes(fill=registrant_city), position = "dodge", stat = "identity") 

我做錯了什么? 請幫忙

我在ui.R文件而不是uiOutput中犯了一個錯誤,我將其更改為plotOutput ,在server.R文件中將其更改為renderPlot

現在一切正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM