I am building a Shiny application with four tabs, each of which displays a plot and three data tables. When I run the application via runApp('app_name'), mostly everything loads correctly. Sometimes the plot won't load, sometimes a data table won't load, and sometimes multiple things will fail to load. And there is the somewhat rare occurrence where everything loads without issue.
The errors have been mostly one of the following:
Error in eval(substitute(expr), envir, enclos) : not compatible with requested type
Error in eval(substitute(expr), envir, enclos) : expected >
Error in eval(substitute(expr), envir, enclos) : filter condition does not evaluate to a logical vector.
The errors occur seemingly randomly and I have not been able to identify any specific part of my code causing the issue. That is, I run the code outside of the Shiny application and cannot replicate the errors.
The strange thing is that the errors occur only on the first tab and disappear upon refreshing the webpage!!
I am pretty stumped with this one, so I'm wondering if anyone has been having a similar issue and how/if they resolved it.
Some other notes that may be helpful:
I'm using dplyr, tidyr, readxl, and ggplot2. I know these have been known to have some errors with shiny
My shiny app always launches with Internet Explorer 11
Thanks for the help and let me know if any further clarification can help.
Sorry for never posting a code snippet to replicate the problem, but I'm pretty sure I have figured out what was going wrong.
Firstly, I originally had library(shiny) as the first line in my ui.R and server.R scripts, followed by source('ui_functions.R') and source(server_functions.R) to reference supporting R code. I tried removing the library(shiny) command from from ui.R and server.R and miraculously the errors disappeared. I have no idea why this worked, but it did.
Secondly, I found that my code only worked on RStudio versions >= 0.99. So if you are getting strange errors like I did, maybe try updating your RStudio verion.
Related
I am trying to create an input-file that can be used for different types of module-identification packages in the "MODifieR"-program, but I get this error message: "The condition has a length>1".
I am still pretty new to R and have just started using these programs so I have no idea what the message means or how to fix it... Greatful for any help!
I haven't tried anything yet, apart from restarting R and reloading all packages/code, as I have little idea of what I am doing :)
Getting a syntax error and not sure why. Trying to loadca dataframe. Please can someone help. Thanks
If you are getting started with programming, jupyter can be counter intuitive at some points, I assume that's not your first cell in the notebook, so be sure to run the previous ones where the definition for titanic_df/titanic_csv is loaded.
The error you are getting says NameError, not SyntaxError, and it is informing you that a variable called titanic_csv does not exist.
So I keep getting an error message in R when I try to use the bias function here's what my code looks like so far:
install.packages("SimDesign")
library(SimDesign)
actual_temp<-c(68.3,70,72.4,71,67,70)
predicted_temp<-c(67.9,69,71,5,70,67,69)
bias(actual_temp, predicted_temp)
And here's the error message I get when I run the code:
Error in bias(actual_temp, predicted_temp) :
ncol(estimate) == length(parameter) is not TRUE
I've tried figuring out if my syntax is off (I'm a novice so I'm never 100% sure). I then tried copy-pasting the error into the search bar and came up with nothing. If anyone has an idea of how to fix this that would be great in case it's a problem I run into again in the future.
Edit: I tried again with some different data and it worked just fine. Is there something in this specific instance you can identify that's making it not work?
When working in RStudio (version 0.99.482 and 1.0.136), if I source a file and an error occur I just get the error message without any context. If the file is longer than a few lines of code, that informaiton is largely useless. What I want to know when an error occurs is the following:
What function threw the error? Preferably what function I called from my script, not something burried deep inside a package.
On what line of my file did the error occur?
This seems like a very basic thing for a scripting language to do, but yet I am unable to find an easy solution. Yes, I am aware of the traceback() function, but (a) it is a hassle to call it every time there is an error, and (b) the output is massive and not that helpful.
I am trying to reproduce simple example with rCharts library to plot sankey chart. I found this example from scratch and tried to reproduce it, however, I came up with some problems.
Firstly I have tried running this code without nothing. Then I found out and realized, that I need d3_sankey in my computer. So, I have downloaded it from here and copied to C:\Users\adomas\Documents\R\win-library\3.0\rCharts\libraries\widgets\d3_sankey.
Then I've tried that unchanged code once more and still got the following error:
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file '/config.yml': No such file or directory
Since that didn't help too, I have tried changing paths from:
sankeyPlot$setLib('libraries/widgets/d3_sankey')
sankeyPlot$setTemplate(script = "libraries/widgets/d3_sankey/layouts/chart.html")
to
sankeyPlot$setLib('C:/Users/adomas/Documents/R/win-library/3.0/rCharts/libraries/widgets/d3_sankey')
sankeyPlot$setTemplate(script = "C:/Users/adomas/Documents/R/win-library/3.0/rCharts/libraries/widgets/d3_sankey/layouts/chart.html")
However, this time, the blank screen in Viewer appeared but no actual Sankey graph and I got the following in console:
Warning message:
In readLines(file, warn = warn, ...) :
invalid input found on input connection 'C:/Users/adomas/Documents/R/win-library/3.0/rCharts/libraries/widgets/d3_sankey/layouts/chart.html
I have tried changing paths and etc, but still something is wrong. And I am not sure if I need to use sankeyPlot$setTemplate at all.
I want to use Sankey chart in my shiny application, but firstly I want to reproduce simply in R. Suggestions would help a lot!
Versions of libraries:
rCharts_0.4.2
igraph_0.7.0
R version: 3.0.2
EDITED:
I have tried this code on different system. And everything works there. Versions of libraries and R are the same and I've copied same documents and just specified full path. I have tried that again on my own computer, but still got the same error yet.
I've experienced the same issues. The solution for me was to upgrade rCharts :
devtools::install_github("rCharts", "ramnathv")
Second, I didn't include the sankeyPlot$setTemplate() line.
Finally, the path in $setLib() should be a direct path (as discribed in the solution of #adomasb or the following line can be used to link directly to the original github:
sankeyPlot$setLib('http://timelyportfolio.github.io/rCharts_d3_sankey/libraries/widgets/d3_sankey')
A downside of this last approach is that internet is always required to run the script.
Alright, eventually it works as it should be.
I just rebooted my system and that's it. However, if anyone would come up with same problem, just be sure you specify direct path, where you placed all necessary files for d3_sankey. Therefore, you rather use
sankeyPlot$setLib('C:/Users/adomas/Documents/R/win-library/3.0/rCharts/libraries/widgets/d3_sankey')
This is wonderful chart type. Good luck!