I built up a shiny solution that is placed in a R-markdown file.
I use runtime: shiny_prerendered
When I do that obviously the code wants to create an html file within the directory but since it is on a network location I do recieve and error:
Error in shiny_prerendered_prerender(input_rmd, rendered_html, output_dir, :
Unable to write prerendered HTML file to \\192.168.88.150/Main/2.Applications/Program/app.html
Calls: <Anonymous> ... shiny_prerendered_html -> shiny_prerendered_prerender
Execution halted
It seems the issue here is that it tries to write to incorrectly specified directory - starting with "\\", rather than "\\\\", for example.
Couple of notes:
When I move the solution to my local pc - works perfectly fine
Everywhere in the code I'm using relative path of the sort "data.R", rather than "\\\\192.168.88.150\\Main\\2.Applications\\Program\\Data.R" since I'm about to move this to shinyapps.io
If I use runtime:shiny it again works perfectly fine on the server but this is probably due to no need to write down a file.
Any idea how to change the path for the html file or other workaround?
I have rights to write on this network location - that's for sure.
Related
I use R/exams to generate a PDF exam like this:
exams2pdf("swisscapital")
However, this results in the following error:
Loading required namespace: tinytex
sh: : Permission denied
Doing the same with exams2html() works well.
What is the problem and how can I fix it?
Given that this does not produce an "error" within R but only on the shell (sh), this is probably just a problem of displaying the PDF interactively at the very end. You can check whether
getOption("pdfviewer")
is correctly set to an application for viewing PDFs (e.g., "/usr/bin/evince") and whether you have permission to use that application.
If there are problems with getting a proper PDF viewer called from within R, then simply use
exams2pdf("swisscapital", dir = ".")
which will write the PDF to your current working directory rather than displaying it in the PDF viewer. And then you can manually open the PDF outside of R.
I am trying to test an shiny application with the function shinytest.
I have made an record and get a new file:
The picture show my test file and how I have specified the path to my application
When I try to run the app I get the following error:
Error in is_rmd(path) :
Unknown whether app is a regular Shiny app or .Rmd: C:/Users/LUCBA/Projects/markt_to_marketpricingtool/test/myshinyapp.R
I know the file is an R file, but I get the error anyway.
Why is this happening and what can I do to fix it?
Best Lucas
This was the code that caused an error in Lucas's original question
app <- ShinyDriver$new("C:/Users/LUCBA/Projects/markt_to_marketpricingtool/test/myshinyapp.R")
The problem is that the first (path) argument to shinytest::ShinyDriver$new can only be a directory (containing either an app.R file or a server.R/ui.R pair) or R markdown .Rmd file. Sadly, a Shiny app file cannot be specified directly by name, so it can't be named myshinyapp.R.
I created an Rshiny APP on my Mac and tried to upload to shinyapps.io
However, when I press 'Publish' button at the top right corner, it shows an error.
Preparing to deploy application...DONE
Uploading bundle for application: 609021...Error in inferAppPrimaryDoc(appPrimaryDoc = appPrimaryDoc, appFiles = appFiles, :
Application mode static requires at least one document.
Calls: <Anonymous> ... withStatus -> force -> bundleApp -> inferAppPrimaryDoc
Execution halted
This problem has been solved. See the first answer.
But now, I have another problem.
I can publish it, but the app cannot show the graphs.
I check the log and it says,
Warning: Error in : Aesthetics must be either length 1 or the same as the data (1): x, y, label, vjust, fill
Also, there is another warning,
Warning in Ops.factor(Year, start) : ‘>=’ not meaningful for factors.
It is pretty strange because when I run the app on my own laptop, it works super well. Please help...
Thanks,
Weichen
You don't have to split your code to ui.R and server.R.
Here is how I solved it on Rstudio:
I created a new Shiny app.R file.
This creates a new folder inside the working directory. I copied all data files I use inside my app into that folder.
I copied and pasted my whole code into the new app.R file on Rstudio.
I clicked Publish and I chose all the data files I use together with the app.R for upload.
It worked. I am not sure why it wasn't working before even though I was still choosing the right files together; I guess because they weren't in the right folder for the Shiny app.
edit: don't forget to Save the app.R file before publishing
Solved.
At first, I simply execute the shiny.R (the whole code) Wrong!
Try this. Create two r files under the same directory.
ui.R
server.R
and then executive shiny.R
You would see an amazing thing happen.
Solved the second problem.
Change the type of 'Year' to numeric by as.numeric
However, I still cannot understand because I can run app on my own laptop.
BTW, the logs in shinyapps.io help me target the problem.
I'm trying to publish an R Shiny app. It works when run locally, but once published to shinyapps.io produces the following error.
Warning in gzfile(file, "wb") :
cannot open compressed file '/key.rda', probable reason 'Permission denied'
Error in value[[3L]](cond) : cannot open the connection
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
You can also see the actual page with the error here: https://povertylab.shinyapps.io/ACS-Map-Dashboard/
Though I have tried to reproduce this error it doesn't appear when I publish other apps, and my searches haven't turned up anything. Other things I've tried: publishing from other computers, publishing only global.R, server.R, and ui.R files, and copying files to a new project and publishing from there.
You can find all code for the app here: https://github.com/Poverty-Lab/ACS-Map-Dashboard
I would appreciate any input, even if it's just guidance on what gzfile is and what the error message could mean. Thank you!
Where is the key.rda file supposed to be? I've looked through your repo and I don't see it, which is probably causing the "cannot open the connection" error.
As a side note, you should probably ignore the .Renviron file; right now anyone can use see and use your key. Make sure you remove it from the history as well.
Thanks all. Turns out this was a problem with the way we were handing the api key for the acs package. We were using api.key.install to install the api key inside the app, and one of api.key.install's default arguments is file = "key.rda", and that file apparently could not be found. I'm still not sure why this problem only came up when we published the app, but we got around it by supplying the actual api key to the acs.fetch function in server.R.
I have set up a Shiny server on Linux at this path
/srv/shiny-server/myApp
This app calls data, which are stored (though a symbolic link) in
/srv/shiny-server/myApp/data/input.txt
and opened with the relative path
"data/input.txt"
When calling this app :
my_ip_adress:3838/myApp
It breaks, not finding the data. I guess it is a path issue, but the idea of a R package is self-containment, so this relative path should be fine.
I have tried with the full path:
"/srv/shiny-server/myApp/data/input.txt"
but get
Warning: Error in fread: File '/srv/shiny-server/myApp/data/input.txt' does not exist. Include one or more spaces to consider the input a system command.
Am I missing something?