Skip to content
Back to skills

R Data Formats

ASecurity

R data format packages for reading/writing files. Use for CSV (readr, vroom), Excel (readxl, writexl), JSON (jsonlite), Parquet (arrow), and fast serialization (fst, qs).

  • 5 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added June 4, 2026
dataapi

Works with

  • api

Security analysis

A100/100

Pro scans all 13 files and shows the line behind each finding

Scanned June 4, 2026

npx -y skills add LeoLin990405/r-analytics-skill --skill r-data-formats --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of R Data Formats?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for R Data Formats
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-r-data-formats/badge)](https://www.skillsdirectory.com/skills/leolin990405-r-data-formats)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: r-data-formats
description: R data format packages for reading/writing files. Use for CSV (readr, vroom), Excel (readxl, writexl), JSON (jsonlite), Parquet (arrow), and fast serialization (fst, qs).
---

# R Data Formats

Reading and writing various data formats.

## CSV/TSV

```r
# readr (tidyverse)
library(readr)
df <- read_csv("data.csv")
df <- read_tsv("data.tsv")
df <- read_delim("data.txt", delim = "|")
write_csv(df, "output.csv")

# vroom (faster for large files)
library(vroom)
df <- vroom("data.csv")
df <- vroom(c("file1.csv", "file2.csv"))  # Multiple files

# Base R
df <- read.csv("data.csv", stringsAsFactors = FALSE)
write.csv(df, "output.csv", row.names = FALSE)

# data.table (fastest)
library(data.table)
dt <- fread("data.csv")
fwrite(dt, "output.csv")
```

## Excel

```r
# Read
library(readxl)
df <- read_excel("data.xlsx")
df <- read_excel("data.xlsx", sheet = "Sheet2")
df <- read_excel("data.xlsx", range = "A1:D100")
excel_sheets("data.xlsx")  # List sheets

# Write
library(writexl)
write_xlsx(df, "output.xlsx")
write_xlsx(list(sheet1 = df1, sheet2 = df2), "output.xlsx")

# openxlsx (more features)
library(openxlsx)
wb <- createWorkbook()
addWorksheet(wb, "Data")
writeData(wb, "Data", df)
saveWorkbook(wb, "output.xlsx")
```

## JSON

```r
library(jsonlite)

# Read
df <- fromJSON("data.json")
data <- fromJSON('{"name": "test", "value": 123}')

# Write
json <- toJSON(df, pretty = TRUE)
write_json(df, "output.json")

# API responses
resp <- httr::GET("https://api.example.com/data")
data <- fromJSON(httr::content(resp, "text"))
```

## Arrow/Parquet

```r
library(arrow)

# Parquet (columnar, compressed)
df <- read_parquet("data.parquet")
write_parquet(df, "output.parquet")

# Feather (fast binary)
df <- read_feather("data.feather")
write_feather(df, "output.feather")

# Arrow datasets (large/partitioned)
ds <- open_dataset("data_dir/", format = "parquet")
ds %>% filter(x > 10) %>% collect()
```

## Fast Serialization

```r
# fst (fastest for data frames)
library(fst)
write_fst(df, "data.fst", compress = 100)
df <- read_fst("data.fst")
df <- read_fst("data.fst", columns = c("a", "b"))

# qs (general R objects)
library(qs)
qsave(obj, "data.qs")
obj <- qread("data.qs")

# RDS (base R)
saveRDS(obj, "data.rds")
obj <- readRDS("data.rds")
```

## Other Formats

```r
# SPSS, Stata, SAS
library(haven)
df <- read_sav("data.sav")   # SPSS
df <- read_dta("data.dta")   # Stata
df <- read_sas("data.sas7bdat")  # SAS

# YAML
library(yaml)
data <- yaml.load_file("config.yaml")
write_yaml(data, "output.yaml")

# XML
library(xml2)
doc <- read_xml("data.xml")

# rio (auto-detect format)
library(rio)
df <- import("data.xlsx")
df <- import("data.sav")
export(df, "output.csv")
```

## Format Comparison

| Format | Speed | Size | Features |
|--------|-------|------|----------|
| CSV | Slow | Large | Universal |
| Parquet | Fast | Small | Columnar, types |
| fst | Fastest | Medium | R-specific |
| Feather | Fast | Medium | Cross-language |
| RDS | Medium | Medium | Any R object |

Files in this skill

  • SKILL.md3 KB
  • arrow/SKILL.md2.6 KB
  • feather/SKILL.md1.2 KB
  • fst/SKILL.md2.4 KB
  • haven/SKILL.md998 B
  • jsonlite/SKILL.md2.2 KB
  • qs/SKILL.md2.4 KB
  • readr/SKILL.md2.7 KB
  • readxl/SKILL.md2.1 KB
  • rio/SKILL.md2.7 KB
  • vroom/SKILL.md2.6 KB
  • writexl/SKILL.md651 B
  • yaml/SKILL.md2.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.