Error in Curl when using geojson_read command in R - 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.

Related

How can I get past this 'SSL connect error' when using jsonlite::fromJSON in R?

Issue
I get the following error whenever I run
all_companies <- jsonlite::fromJSON("https://www.sec.gov/files/company_tickers_exchange.json")
Warning: URL 'https://www.sec.gov/files/company_tickers_exchange.json': status was 'SSL connect error'Error in open.connection(con, "rb") :
cannot open the connection to 'https://www.sec.gov/files/company_tickers_exchange.json'
Thank you in advance for any help!
What I've tried
I am trying to run this on a new work computer, it runs fine on my old work computer but the new one gives me this error.
It seems the difference causing this issue is that I am using {jsonlite} 1.8.2 on my new computer and 1.8.0 on my old computer. Deep in the definition of the fromJSON() function, the working version seems to use curl::curl() to establish a connection whereas the not-working version uses base::url().
The following example line from the help documentation runs fine on the new computer with version 1.8.2
data1 <- fromJSON("https://api.github.com/users/hadley/orgs")
I can access the JSON file I am trying to read on an internet browser.
I do not have permission to install Rtools on my computer to be able to compile an older version of {jsonlite}.

R Studio crashing not at initialization. Error: Error occurred during transmission

Some context on my environment:
I am running R Studio in a docker container called rocker/verse.
I downloaded this dataset from Kaggle, which has about 470 MB.
When working with it, at some point RStudio restart. It does't happen after a specific call, and I've seen the same problem when working with other projects. Though it is not related to my code, I am posting it bellow.
library(data.table)
fraud<- fread("path.csv")
fraud1<- sort(sample(nrow(fraud), nrow(fraud)*.7))
train<- fraud[fraud1, ]
test<-fraud[-fraud1, ]
Usually on the console this message is printed:
Error: Error occurred during transmission
And, this pop up is also showed:
I have no idea what is causing it. I would appreciate any help.
Delete the .Rhistory files associated with the installation and any open project.
You have a problem with your user data files for Rstudio. Follow the hints given here: https://community.rstudio.com/t/rstudio-server-error-occurred-during-transmission/84258 and here: https://support.rstudio.com/hc/en-us/articles/218730228-Resetting-a-user-s-state-on-RStudio-Server.

fatal error on loading my trained keras model in r

I have h5 model already trained. I want to load that model to my r application.
Code used is :
library(keras)
m <- keras::load_model_hdf5("www/ae_model.h5")
Even tried:
m <- load_model_hdf5("www/ae_model.h5")
My R session asks for restart.
it shows R session Aborted R encountered a fatal error. The session was terminated on my screen.
I could solve this issue by myself, I made sure that the file is stored in my current working directory. and added another "/" to the URL i.e
m <- load_model_hdf5("www//ae_model.h5").
To my existing code. Thank you for the response.

as.h2o ERROR: Unexpected HTTP Status code: 500 Server Error

I'm trying to do something with h2o in Rstudio, but have problems when using as.h2o(). It always gives back the following error.
For example:
library(h2o)
localH2O = h2o.init()
finaldata.hex = as.h2o(finaldata)
ERROR: Unexpected HTTP Status code: 500 Server Error (url = http://localhost:54321/3/PostFile?destination_frame=%2Fprivate%2Fvar%2Ffolders%2F8z%2F29h4lb311gbdhg58mj704g580000gn%2FT%2FRtmpr83spR%2Ffile12ab3b8df30c.csv_sid_a24d_3)
Error: lexical error: invalid char in json text.
<html> <head> <meta http-equiv=
(right here) ------^
Would you please help me to figure out how to fix this error?
Thanks,
This is super late but I had the same issue and I realized that increasing h2o.glm(...,max_mem_size) made that issue go away. I was converting an extremely large data.table to to an h2o object and was getting this same error message.
This problem is when you are using h2o to change the data frame to h2o format as:
data_h2o <- as.h2O(data)
This is internal error for your Server.
To solve this problem you can restart your server and run it again. I hope this can help you...

RStudio cannot find any package after laptop restart

My R script worked fine in RStudio (Version 0.98.1091) on Windows 7. Then I restarted my laptop, entered again in RStudio and now it provides the following error messages each time I want to execute my code:
cl <- makeCluster(mc); # build the cluster
Error: could not find function "makeCluster"
> registerDoParallel(cl)
Error: could not find function "registerDoParallel"
> fileIdndexes <- gsub("\\.[^.]*","",basename(SF))
Error in basename(SF) : object 'SF' not found
These error messages are slightly different each time I run the code. It seems that RStudio cannot find any function that is used in the code.
I restarted R Session, cleaned Workspace, restarted RStudio. Nothing helps.
It must be noticed that after many attempts to execute the code, it finally was initialized. However, after 100 iterations, it crashed with the message related to unavailability of localhost.
Add library(*the package needed/where the function is*) for each of the packages you're using.

Resources