I have created a shiny app which works fine but when I try to deploy it to shinyapps.io I get the following error. Error in value[[3L]](cond) : object 'all2' not found
. Why can't it locate all2
? My original file is an excel file which I have stored in my working directory and uploaded it inside rstudio
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(visNetwork)
library(shinyWidgets)
library(igraph)
shinyApp(
ui = dashboardPagePlus(
header = dashboardHeaderPlus(title = "Network Viz."
),
sidebar = dashboardSidebar(
pickerInput(
inputId = "ctype"
,
label = "Select Country"
,
choices = unique(all2$Country)
,
selected = unique(all2$Country)[1],
multiple = T,options = list(`actions-box` = TRUE)
),
uiOutput("lang"),
uiOutput("top")
),
body = dashboardBody(#This hides the temporary warning messages while the plots are being created
tags$style(type="text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
),
visNetworkOutput("network")
)
),
server = function(input, output) {
ID<-c(1,2,3,4)
Name<-c("j","dd","ff","fcf")
Language<-c("en","fr","gr","gh")
Country<-c("EN","FR","GR","GRE")
Topic<-c("sc","sc","ghgf","vb")
Follow<-c(34,56,76,76)
Social<-c("Facebook","Facebook","Twitter","Twitter")
all2<-data.frame(ID,Name,Language,Country,Topic,Follow,Social)
dtnew<-reactive({
new<-subset(all2, Country %in% input$ctype)
})
output$lang<-renderUI({
pickerInput(
inputId = "l1",
label = "Select Language",
choices = unique(dtnew()$Language),
multiple = TRUE,
selected = unique(dtnew()$Language)[1],
options = list(`actions-box` = TRUE)
)
})
output$top<-renderUI({
pickerInput(
inputId = "t1",
label = "Select Topic",
choices = unique(dtnew()$Topic),
multiple = TRUE,
selected = unique(dtnew()$Topic)[1],
options = list(`actions-box` = TRUE)
)
})
dtnew2<-reactive({
new2<-subset(all2, Country %in% input$ctype&Language%in% input$l1&Topic%in% input$t1)
})
output$network <- renderVisNetwork({
nodes<-dtnew2()
nodes<-nodes[,-c(3,4)]
nodes<-nodes[,-4]
colnames(nodes)<-c("id","label","group","Platform")
nodes$value<-nodes$id
id<-c(nrow(nodes)+1,nrow(nodes)+2)
label<-unique(nodes$Platform)
group<-c("Social","Social")
Platform<-unique(nodes$Platform)
value<-c(nrow(nodes)+1,nrow(nodes)+2)
ft<-data.frame(id,label,group,Platform,value)
nodes<-rbind(nodes,ft)
nodes<-nodes[!duplicated(nodes[2]),]
nodes<-nodes[,-4]
nodes$id <- nodes$label
nodes$value <- seq.int(nrow(nodes))
nodes$title<-paste0("<p>","Name:",nodes$label,"<br>","Group:",nodes$group,"</p>")
edges<-dtnew2()
edges<-edges[,c(2,6,7)]
colnames(edges)<-c("from","value","to")
edges$title<-edges$value
visNetwork(nodes, edges, height = "500px", width = "100%") %>%
visOptions(highlightNearest = list(enabled = T, hover = T),nodesIdSelection = T) %>%
visLayout(randomSeed = 123)%>%
visInteraction(navigationButtons = TRUE)%>%
visIgraphLayout()
})
}
)
ok I found it I had to place
before
shinyApp()