Loading an RDA file into R


I'm very new to using R, so this might hopefully be a very easy question for some of you.

I'm trying load a RDA file which should contain some data.

Professor says to use readRDS, however r gives this long error message which I've not been able to decipher myself.

I hope that someone are able to provide some clever solution to this problem.

Canteen_clean <- readRDS("C:/Users/a_s_j/OneDrive/Studie/Cand.merc.Business Intelligence/1. Semester/R for Business Analytics/.Rproj/39 - Graphics/Exercises02/canteen_clean.rds") Error in gzfile(file, "rb") : cannot open the connection In addition: Warning message: In gzfile(file, "rb") : cannot open compressed file 'C:/Users/a_s_j/OneDrive/Studie/Cand.merc.Business Intelligence/1. Semester/R for Business Analytics/.Rproj/39 - Graphics/Exercises02/canteen_clean.rds', probable reason 'No such file or directory'

I'm using:
pacman::p_load("pacman", "tidyverse") to load the packages that should be necessary.

Thank you

Hi @ASJ,

Neither pacman nor tidyverse are needed to use readRDS(). It is a base R function that is loaded by default.

The likely issue if you have not pointed R to the right location for the file. You can reproduce the error by running this code:


Which points R to a file foo which doesn't exist. Double check that you have the correct path to the file.

Thank you. I found a solution.

filename <- file.choose("canteen_clean")
Canteen_clean <- readRDS(filename)

Thank you

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.