readr in R
read_csv is faster than read.csv, and it tells you what it guessed.
library(readr)
library(dplyr)
text <- "day,lang,tpm,note\n2026-07-29,r,96,\n2026-07-30,python,104,fast\n"
runs <- read_csv(text,
col_types = cols(
day = col_date(format = "%Y-%m-%d"),
lang = col_character(),
tpm = col_integer(),
note = col_character()
),
na = c("", "NA"))
print(runs)
print(sapply(runs, class))
path <- tempfile(fileext = ".csv")
write_csv(runs, path)
print(nrow(read_csv(path, show_col_types = FALSE)))
How it works
col_typesstops the guessing and documents the schema.nasays which strings mean missing.problems()reports the rows that did not fit.
Keywords and builtins used here
ccol_charactercol_datecol_integercolslibrarynrowprintread_csvsapplytempfilewrite_csv
The run, in numbers
- Lines
- 19
- Characters to type
- 423
- Tokens
- 104
- Three-star pace
- 100 tpm
At the three-star pace of 100 tokens a minute, this run takes about 62 seconds.
Step 1 of 3 in Reading & selecting, step 9 of 12 in Reshaping & reading.