【发布时间】:2021-01-31 01:53:59
【问题描述】:
我是闪亮应用程序的新手,正在尝试编写简单的代码。 我更改了很多次代码,但我的条形图不起作用。 我在其他尝试中遇到了这个问题。 UI 可以工作,服务器中的代码也可以在 R 中部分工作,但不能在闪亮的应用程序中工作。我知道我的服务器的某些部分不是我想要的,我只想知道我应该怎么做才能运行在 R 中有效但在 Shiny 中无效的代码
#Graph 2
server<-#Graph 2
library("tidyverse")
library("leaflet")
library("leaflet.extras")
library("rnaturalearthdata")
library("sf")
library("DT")
library("ggplot2")
N <- read.csv("https://data.ontario.ca/dataset/f4112442-bdc8-45d2-be3c-12efae72fb27/resource/455fd63b-603d-4608-8216-7d8647f43350/download/conposcovidloc.csv")
function(input, output, session){
if(input$data.Gender){
City ="Ottawa"
N %>% subset(Reporting_PHU_City == City) %>%
select(Case_Reported_Date, Age_Group, Client_Gender, Outcome1)%>%
rename(Date = Case_Reported_Date)%>%
arrange(Age_Group, Client_Gender, Outcome1)
Data.N <- as.data.frame(N)
Data.N %>%
group_by(Age_Group) %>%
summarise(Age = n_distinct(Age_Group)) %>%
arrange(desc(Age))
w = table(N$Age_Group)
t = as.data.frame(w)
}
output$Plot <- renderPlot({
ggplot() +
geom_bar(stat = "identity",data = t,mapping = aes(x = N$Client_Gender , y =Freq))
})
}
【问题讨论】: