plotly partial_bundle fails with timeout error - r

I'm trying to increase the performance of a markdown which has a lot of plotly graphs in it by using the partial_bundle function. I'm using the code from the ?partial_bundle for the reprex
Unfortunately it fails with the error message:
Error in curl::curl_download(paste0("https://cdn.plot.ly/", bundle_script), :
Timeout was reached: [] Connection timed out after 10012 milliseconds
plot_ly(z = ~volcano) %>%
add_heatmap() %>%
partial_bundle()
Now I am behind a VPN at work, so I assume that is causing an error, but unsure how to redirect the package if needed. Also is there a way to download the required "bundle" directly from the cdn or npm package directly, as listed here https://github.com/plotly/plotly.js/blob/master/dist/README.md
?
Many thanks. I appreciate that as this isn't reproducible (you'd need to be behind my VPN), just wondered if anyone else had come across this issue and resolved it!

Related

Circularity detected when running (vega:load-vega-examples)

When I load the vega-lite data sets using
(vega:load-vega-examples)
I get the following error:
Could not REQUIRE CL-DATE-TIME-PARSER: circularity detected. Please check your configuration
However, the examples appear to have loaded.
Also, before I installed cl-date-time-parser in quicklisp, I was getting an error message similar to:
Do not know how to REQUIRE CL-DATE-TIME-PARSER
Does anyone know how to get rid of these errors?
Many thanks!
The IMDB example requires cl-date-time-parser. I suspect that problem is that (require ...) only works when the library is in a location known to ASDF. In a new installation, this may not be the case. Now reported as issue #19.
Try loading the library with quicklisp and then rerunning load-vega-examples.

Issues installing Plotly Dash for R

I'm trying to install the newly released Plotly Dash package for R as described on plotly website https://dashr.plot.ly/installation, i.e. running
library(devtools) # devtools: Tools to Make Developing R Packages Easier
# The following statement will also install dashCoreComponents,
# dashHtmlComponents, and dashTable
install_github('plotly/dashR') # The core dash backend
This is what it returns, 'unknown package' any help much appreciated
Error: Failed to install 'unknown package' from GitHub:
HTTP error 403.
API rate limit exceeded for 86.134.113.102. (But here's the good news:
Authenticated requests get a higher rate limit. Check out the
documentation for more details.)
Just installed the package to reproduce the error, unfortunately can't be able to reproduce it. However, a potential solution along "error 403 and
API rate limit exceeded ..." could be to add your github authorization token in your .Rprofile and that is what the "But here's the good news:" message inside the bracket is trying to inform you. Have a look at the actual project github site Dash for R if you haven't already. That might as well provide you an input to solving the issue.

R Script running successfully on local machine, not on EC2 instance

I have an R script (an R plumber API) that I have deployed to an EC2 instance and managing with pm2, and I am running into a struggling issue. I have pinpointed the exact location of the error, and am hoping to understand this error a bit better.
When I run the script on my local machine (RStudio on my Mac) it works okay. When I run the script using Rscript myrfile.R from the EC2 instance command line, it breaks.
I have pinpointed that the line of code that breaks the script the on EC2 instance, as well as its error, are:
my_df <- my_df %>%
dplyr::mutate(AwayScore = ifelse(dplyr::row_number() == 1, 0, AwayScore),
HomeScore = ifelse(dplyr::row_number() == 1, 0, HomeScore))
# with the following error
<Rcpp::eval_error in mutate_impl(.data, dots): Evaluation error: argument "x" is missing, with no default.>
I am 100% sure that dplyr is installed on the EC2 instance, since my script uses it throughout. I am also 100% sure that the my_df dataframe here has the columns AwayScore and homeScore, and also that my_df doesnt have any other issues.
I am left to assume that this error is specifically due to the dplyr::row_number() function, which the EC2 instance does not seem to be able to handle, although I am not positive on this.
Any thoughts / help / things I should try / etc. would be greatly appreciated on this, thanks!!
While I appreciate you have avoided the problem by not requiring the library, at some point you may find you want to run codes in a similar way where loading a library will be necessary.
I ran into a similar problem using R script. I found it could not find the libraries I had installed. It is possible to use R.exe instead of Rscript.exe, but this causes other headaches. I found that the environment when using Rscript doesn't contain the R_LIBS_USER path
If you append the following code to the top of your R script it should work
p <- "\directory path of local R packages"
.libPaths(c(p,.libPaths()))
putting the folder path to where your libraries are found on the computer. This is the path that would be returned by Sys.getenv("R_LIBS_USER") if running R in the GUI
It was easy enough for me to simply change my code to the following:
if(is.na(my_df$AwayScore[1])) { my_df$AwayScore[1] = 0 }
if(is.na(my_df$HomeScore[1])) { my_df$HomeScore[1] = 0 }
... so I will likely not waste too much more time trying to debug this.

Error in Curl when using geojson_read command in R

My situation is I wrote an R script using a university windows computer and emailed the file to myself. The first and second time I ran the script it was working perfectly, however, I started having the following error on the third run.
I figured out the line causing the problem and the error message:
> mapdt <-
> geojson_read("http://maperic.clst.org/wupl/Stuff/gz_2010_us_040_00_500k.json",
> what = "sp")
Error in curl::curl_fetch_disk(url, x$path, handle = handle) :
Timeout was reached
I have tried http_proxy method in this link, and it was not working properly. I have the same problem in two different network environment.
Thank you.

Error handling in R in RStudio -- don't invoke debugger?

I'm trying to create error messages similar to those you can find in R package dplyr that don't invoke RStudio's debugger and simply stop and print an informative message.
So for example in RStudio if you use:
library(dplyr)
group_by(blah)
You get an informative error but the debugger is not invoked so the "interruption" to the user is minimal, they realize the issue and fix the code. But when I use
myfunc<-function(val){
if(val>3) stop("This is error", call.=FALSE)
}
myfunc(4)
The debugger is triggered and it's more unpleasant. How do I simply give a nice error message with out starting the debugger? What is the difference in how dplyr is creating error messages and mine? I did look at the GitHub repo but wasn't sure.

Resources