When trying to get working Shiny App into shinyapps.io it does not work. After trying numerous ways how to include my "counties" dataset to be read by the shinyapps.io it keeps giving the following error: cannot open file './counties.csv': No such file or directory + Warning: Error in file: cannot open the connection
This is th code I use for ui.R
library(shiny)
library(ggplot2)
library(ggiraph)
library(readr)
counties <- read.csv("./counties.csv")
shinyUI(fluidPage(
# Application title
titlePanel("Spatial Distribution of Protest Events in Iran during 2005 - 2017"),
sidebarPanel(
selectInput(
inputId = "counties",
label = "Protest Event Issue",
choices = list("freq_prov_tot", "freq_prov_bio", "freq_prov_air", "freq_prov_def","freq_prov_wast", "freq_prov_green", "freq_prov_wat", "freq_prov_ind", "freq_prov_gen", "freq_prov_eff",
"freq_prov_plas", "freq_prov_cult", "freq_prov_cult", "freq_prov_flo", "freq_prov_haze", "freq_prov_clean", "freq_prov_add", "freq_prov_nat", "freq_prov_soil", "freq_prov_trees", "freq_prov_veh"), selected = "freq_prov_bio"
)
),
fluidRow(column(12,
ggiraph::ggiraphOutput("county_map")))
)
)
And this is the code for the server
library(shiny)
library(ggplot2)
library(ggiraph)
library(readr)
shinyServer(function(input, output) {
data2 <- observeEvent(input$counties, {
if (input$counties == "freq_prov_bio"){
output$county_map<- renderggiraph({
p<- ggplot(counties, aes(x=long, y=lat, group = group, fill = freq_prov_bio)) +
xlab("Longitude") + ylab("Lattitude") + labs(fill = "Number of Protest Events\n regarding Biodiversity") + scale_fill_gradientn(colours = c(low = "grey", high = "black"), breaks=c(0,5,10,15), labels=c(0,5,10,15), limits=c(0,20)) +
coord_map("polyconic" ) +
geom_polygon_interactive(aes(tooltip = labs_bio))
ggiraph(code = print(p)) })}
etcetera
If there is any clue on how to fix this, please do let me know.
Getwd() gives the following: "C:/Users/Gebruiker/Documents/Earth Science Scriptie"
In this folder all my data + scripts are saved.
Data
(or something) in the working directory, then usecounties <- read.csv("Data/counties.csv")
– nogbadsetwd("C:/Users/Gebruiker/Documents/Earth Science Scriptie")
I get the following error: Error in setwd: cannot change working directory – SofieCroonenberg