I am working on a RStudio shiny app that reads in a geojson file then creates a map using leaflet.
I take my geojson file, and put it in my /data folder prior to publishing.
Overall, everything works great. I am consistently changing some polygons in my geojson file, so I overwrite the old file and load the new all within the shiny app using an actionButton.
Things work great on my local machine but when I publish the app and use it on the web, my map file doesn't overwrite.
Is there a permissions issue within RStudio shiny?
I have also looked into using Google drive or dropbox to load then rewrite the file and have not had any luck.
Related
I am hoping to include a widget in my R shiny app where the user can select a folder destination for output files to be saved in. I've tried using the shinyDirChoose and shinyDirButton, and they work, but moving through the file directory is very slow. I'd like to have the speed of fileInput and the ability to select a folder, rather than a file, as the file input (even though it would really be used for output). Is there a MIME type for folders in Windows Explorer that I could specify in fileInput? Or is there a way to speed up shinyDirChoose?
I can make a R-Leaflet map in RStudio and export to html.
Here's the senario, a client has limited web infrastructure, basic webhosting: no database, no shiny server, no r-server etc.
They want an online map on their website which can be updated (by them), so how can I link the html so it looks up the coordinate from a file rather than being hard coded in the script (e.g. through src="lat-long.csv"). Alternatively could a shape file be accessed (using the SP library)? Or even a Geojson file.
I'm working on loading up a Shiny App IO. I use an R package that downloads data into a subfolder in my directory and saves two .RData files.
I'm having issues on the Shiny App IO server. I need to load the two .RData files. Locally, I can set the relative path using (~project/source-data). Shiny App does not respond to this.
I can set it as a working directory using a relative path, (./source-data), however, this is not ideal as I have further data manipulation to do at the parent level directory and I can't seem to set the working directory back to the parent level in Shiny App.
Here is what I had moved forward with:
wd = getwd()
sd = (paste(getwd(),"/source-data",sep=""))
sd2 = list.files(sd, full.names = TRUE)
file.copy(from=sd2, to=wd)
My solution, although not ideal, is to copy the two .RData files to the parent directory. At that point, the rest of my code will run smoothly. It works locally, but not on Shiny App.
Does anyone have experience with a similar problem and solution? Either helping me direct the Shiny App IO server to the sub-directory and back to the parent directory once I load in the two .RData files, or copying the files to the parent directory?
I've seen solutions that work on a local R environment, but not one that satisfies the conditions of a Shiny App IO server environment.
Thank you in advance.
I'm deploying my shiny app and I don't know how to input my a local dataset. I keep getting Error: object "data" not found. Here is my path to shiny folder.
library(shinyapps)
shinyapps::deployApp('C:\\Users\\Jeremy\\Desktop\\jerm2')
In this directory (jerm2), I have 3 things: ui.R, server.R, and my local dataset, a .csv called proj.csv.
In the server.R file,
I set data<-read.csv("proj.csv")
I just don't know how to get Shiny to pick up my datasets.
You may want to add a subdirectory in your shiny folder called "Data" and put proj.csv there.
Then, in your server.r put:
data<-read.csv("./Data/proj.csv")
That will make it clear where the data is when the app is deployed to the ShinyApps service.
I ran into this same problem. It turned out that I did not have my working directory pointing to my shiny app at the time I used shiny.io to save and deploy my app.
Be sure that if you're loading the data that the code reflects that your shiny app is the working directory.
Otherwise you will get a log error that looks something like this
cannot open compressed file 'C:/Users/Joseph/Documents/data/data.rda', probable reason 'No such file or directory'
What I did was to write the csv under a sub folder (i.e. data/) of the shiny app directory and then added data<-read.csv("/Data/proj.csv") in server.r (as indicated in the answer). I didn't put the dot and it works.
Another thing is, when you publish it, don't forget to publish both the shiny app and the file in the shiny app folder.
I was wondering if its possible to somehow given a dropbox folder link, download all files in that folder in to R?
If not is is possible, how would one be able to upload files onto Shiny Server so maybe I could source them locally?
Thanks,