Exploring Medical Data Science with R

Exploring Medical Data Science with R

Foundations

Sec.1-Ch.2-Subsec.7:Mastering Data File Handling in R: RDS, RData, CSV & TXT

A Practical, Hands-On Guide to Reading and Writing Common Data Formats in R

Dr. Xie YJ's avatar
Dr. Xie YJ
Jan 21, 2026
∙ Paid

In the world of data science and statistics, reading and writing data is a fundamental task. R provides multiple ways to handle different types of data files. In this guide, we’ll go through how to read and write four common file formats in R: .RDS, .RData, .CSV, and .TXT. These formats are widely used for data analysis, storage, and sharing, so knowing how to handle them is essential for any data scientist.


1. RDS and RData Files

When working in R, saving and loading data is a core part of analysis. R has two native file formats for storing data: RDS and RData. Both are very useful within R because they store data efficiently while keeping the structure and attributes intact. If you only use R and don’t need to move your data to other platforms, these formats are the go-to choice.

RDS format stores a single R object—like a data frame, list, or model. Since it’s stored in binary, the files are usually small, and reading them preserves the object’s structure and attributes.

A cool feature of RDS is that you can assign a new name to the object when reading it back, which makes handling multiple versions of data or models in the same session much easier. RDS files might be slightly slower to save or read than some alternatives, but their efficient storage and flexibility make them very popular.

Here’s a quick comparison of XLS (Excel), CSV, RDS, and RData formats:

User's avatar

Continue reading this post for free, courtesy of Dr. Xie YJ.

Or purchase a paid subscription.
© 2026 Xie Yaojue · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture