how to create an rds file

How can I create a file like "counties.rds" used in the lesson 5 of shiny tutorial?
I want to create a file like that four the differents cities of my country.

The file link:


Hi, and welcome!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers. (However, this question doesn't require one.)

To create an Rds file in the current working directory

save(an_object, file = "an_object.Rds")

and to read it back in


save and load use the .RData or .rda extension. OP is searching for saveRDS and readRDS. Please see this.

Either works. I prefer save because it preserves the object name by default.

Sure, it works but using save and load along with the ext. rds is misleading (restore env. or not).

Different strokes for different folks.

If you do it this way.. fine for me, but please don't "teach" it to others.

By the way, have you tried running load("counties.rds"), after downloading the referenced file, as your post suggests? - an error is all you'll get (because the file was written via saveRDS not save).

Using counties <- readRDS("counties.rds") works fine (Restore a single R object without it's earlier name).

If you still feel the need to "introduce me to some of the moderators" regarding my posts, as proposed in your PM, please feel free to do so.


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