简体   繁体   English

如何在闪亮的仪表板上使用dplyr制作条形图

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

I am trying to make a bar plot in renderUI in shiny dashboard. 我正在尝试在闪亮的仪表板的renderUI中绘制条形图。 Following is my code 以下是我的代码

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 is a function which returns a dataframe after cleaning and munging of a dataframe clean_data是一个在清理和整理数据帧之后返回数据帧的函数

Whenever I run shiny app it gives me Error:Mapping should be created with aes() or aes_() .` I do not know what exactly this means. 每当我运行有光泽的应用程序时,都会出现Error:Mapping should be created with aes()或aes_() Error:Mapping should be created with 。`我不知道这到底意味着什么。 When I run the same code in R console it gives me a proper ootput. 当我在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") 

What I am doing wrong? 我做错了什么? please help 请帮忙

I got it where i was committing a mistake, in ui.R file instead of uiOutput I changed it to plotOutput and in the server.R file I changed it to renderPlot 我在ui.R文件而不是uiOutput中犯了一个错误,我将其更改为plotOutput ,在server.R文件中将其更改为renderPlot

Now everything works fine. 现在一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM