I'm trying load a rds
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'm trying to load the file and place it in an Object.
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.
To successfully load this file into R, you can use the read. table() function in which you specify the separator character, or you can use the read. csv() or read. csv2() functions.
R also has two native data formats—Rdata (sometimes shortened to Rda) and Rds. These formats are used when R objects are saved for later use. Rdata is used to save multiple R objects, while Rds is used to save a single R object. See below for instructions on how to read and load data into R from both file extensions.
The easiest way to load the data into R is to double-click on the particular file yourfile. RData after you download it to your computer. This will open in RStudio only if you have associated the . RData files with RStudio.
rds files are serialized, you don't want to edit the file directly. Load the object, change the things you need changed and then re-save the new object.
Rather than typing a long file path, a really good idea in R is to let the system do the typing for you. That is, do something like this:
filename <- file.choose()
Canteen_clean <- readRDS(filename)
The first line will open the usual file open dialog box; you can select the file you want, and the name will be stored in the filename
variable. The second line will use that name to open it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With