Error in readRDS("<Rds file name here>") : error reading from connection


#1

Howdy,
I'm looking to use this http://shiny.rstudio.com/gallery/google-charts.html as an example and start to dig into how I can use my data with a display like this bubble graph with the slider.

I've copied the code and downloaded the RDS file. I even got it all running yesterday but now today I get this error:

Error in readRDS("healthexp.Rds") : error reading from connection

I've;

checked spelling (all fine)
checked that WD is correctly set
run another shiny app locally (all fine)
updated R to the latest version for MAC 1.1.453
searched the internet with no luck

Thoughts?


#2

It's possible your working directory has changed; use getwd() to see what it is. If it's different than you expect, you can use setwd() to change it to the directory that healthexp.Rds is in. Or better yet, use RStudio projects and never mess with your working directory--instead copy the assets you need (like the .Rds file) into the project directory.


#3

WD was the first thing I thought of as well, no luck there. I've even tried starting over in a new folder. No luck with any of that.

I created a project and copied files into folder, still no luck.

Any other thoughts appreciated?


#4

The error message error reading from connection is most commonly an issue with one's filepath.

When I am confused by where an RDS files is relative to my working directory, I use RStudio's file pane to navigate to the offending file, click on it and open. The R console then reveals it's location.

Compare that to the current working directory getwd()


#5

Yep, done a lot of playing around as noted with path. None of these path descriptions work. Same error with each.

Notes: R Project gives same issue, restarting R no resolution, starting over copying files from web in R project or just normal directory no luck either.


#6

What happens when you load the rds vis the Load R Object gui? (You console doesn't show the attempt yet)


#7

same error.

healthexp <- readRDS("~/Data/shinny/googlebubble71818/healthexp.Rds")
Error in readRDS("~/Data/shinny/googlebubble71818/healthexp.Rds") :
error reading from connection

Interestingly I pushed this to shiny.io and it has same error.
https://markloessi.shinyapps.io/googlechartsProj/

Something wrong with the file ? maybe.


#8

Tried installing rio to import RDS but same error :frowning:


#9

So, I downloaded the RDS file again from JCheng GitHub account and that fixed the issue.

For completion sake I did have to change %.% to %>% in this bit of code to get it to run in my environment (noted above).

df <- data %>%
  filter(Year == input$year) %>%
  select(Country, Health.Expenditure, Life.Expectancy,
         Region, Population) %>%
  arrange(Region)

Thanks for all the attempts to help, much appreciated!