私はニューヨークの犯罪歴データに基づいて光沢のあるアプリを作ろうとしています。私は単一の光沢のあるページのアプローチを使用しています。ここにデータがあります:犯罪統計を出力する年を何らかの理由で選択すると、私の出力はRStudioのビューアでのみ出力され、Shinyポップアップのメインパネルでは出力されません。ここでは、完全なコードは次のとおりです。光沢のあるプロットプロットを正しく出力するには?
# Shiny App exploring New York City Crime Data between 2006-2016
# Data Source: https://data.world/data-society/nyc-crime-data
#########################Global Data######################
# Data Reading
set.seed(123)
library("shiny")
library("lubridate")
library("plotly")
nypd<-read.csv("NYPD_Complaint_Data_Historic.csv")
#Data Massaging
nypd$year<-year(as.Date(nypd$RPT_DT,'%m/%d/%Y'))
nypd$month<-month(as.Date(nypd$RPT_DT,'%m/%d/%Y'))
nypd<-nypd[nypd$OFNS_DESC != "",]
nypd2<-nypd[,c(1,6,8,14,16,17,22,23,25,26)]
ui<-fluidPage(
titlePanel("New York City Crime Data from 2006-2016"),
sidebarLayout(
sidebarPanel(
sliderInput("year","Year of Crime",min=2006,max=2016,value=2008,step = 1)
),
mainPanel(plotOutput("crimeplot"))
)
)
server<-function(input,output){
output$crimeplot<-renderPlot({
nypd_yr_sorted<-nypd2[nypd2$year==input$year,]
agg_data<- aggregate(nypd_yr_sorted$CMPLNT_NUM,by=list(nypd_yr_sorted$OFNS_DESC),FUN=functi on(x)length(unique(x)))
colnames(agg_data)<-c("Crime","Crime count")
bar_data<-agg_data[order(agg_data$`Crime count`, decreasing = TRUE),][1:5,]
plot_ly(bar_data,x=~Crime,y=~`Crime count`,type="bar",color = ~Crime) %>% layout(xaxis= list(showticklabels = FALSE))
})
}
shinyApp(ui = ui, server = server)
:
output$crimeplot<-renderPlotly({
から
mainPanel(plotlyOutput("crimeplot"))
mainPanel()
変更output$crimeplot
...と、出力:二つの要求されるコードの変更サイズが数百MBのデータファイル。あなたは、少なくとも巨大なファイルをダウンロードせずにあなたのアプリを再現できるように、いくつかの行をコピーして貼り付けることができますか? – Phil@ Phil - 実際には1.3GBですが、友人の中で何百メガバイトですか? –
@ Piyush - あなたは私の答えに記載された変更を加えて、あなたの光沢のあるアプリを動かすことができましたか? –