readr Exercises in R: 30 Real Practice Problems
Thirty practice problems on readr: reading and writing CSVs, custom NAs, column types, locales, parsing helpers. Hidden solutions, runnable code.
Section 1. Reading basics (8 problems)
Exercise 1.1: read_csv
Difficulty: Beginner. Write and re-read a small CSV.
Show solution
Exercise 1.2: read_tsv
Difficulty: Beginner.
Show solution
Exercise 1.3: Read with custom NA strings
Difficulty: Intermediate.
Show solution
Exercise 1.4: Skip lines
Difficulty: Intermediate. Skip first 2 rows.
Show solution
Exercise 1.5: First N rows only
Difficulty: Beginner. Read 5 rows.
Show solution
Exercise 1.6: From a string
Difficulty: Intermediate.
Show solution
Exercise 1.7: Read without column names
Difficulty: Intermediate.
Show solution
Exercise 1.8: Custom column names
Difficulty: Intermediate.
Show solution
Section 2. Column types (6 problems)
Exercise 2.1: Force a column to character
Difficulty: Intermediate.
Show solution
Exercise 2.2: Compact spec string
Difficulty: Intermediate. cidD = char/int/double.
Show solution
Exercise 2.3: Skip a column
Difficulty: Intermediate.
Show solution
Exercise 2.4: Date column
Difficulty: Intermediate. Parse a date column.
Show solution
Exercise 2.5: Custom date format
Difficulty: Advanced.
Show solution
Exercise 2.6: Spec problems
Difficulty: Advanced. Inspect parsing problems.
Show solution
Section 3. Parsers (8 problems)
Exercise 3.1: parse_number from currency
Difficulty: Intermediate.
Show solution
Exercise 3.2: parse_double
Difficulty: Beginner.
Show solution
Exercise 3.3: parse_logical
Difficulty: Intermediate.
Show solution
Exercise 3.4: parse_date
Difficulty: Intermediate.
Show solution
Exercise 3.5: parse_datetime
Difficulty: Intermediate.
Show solution
Exercise 3.6: parse_number with custom locale
Difficulty: Advanced. Parse "1.234,50" (European).
Show solution
Exercise 3.7: parse_factor
Difficulty: Intermediate.
Show solution
Exercise 3.8: parse_guess
Difficulty: Advanced.
Show solution
Section 4. Writing (4 problems)
Exercise 4.1: write_csv
Difficulty: Beginner.
Show solution
Exercise 4.2: write_excel_csv
Difficulty: Intermediate. Excel-friendly UTF-8 BOM.
Show solution
Exercise 4.3: write_rds for round-trip
Difficulty: Intermediate.
Show solution
Exercise 4.4: Append rows
Difficulty: Advanced.
Show solution
Section 5. Real-world workflows (4 problems)
Exercise 5.1: Read a messy file
Difficulty: Advanced. Skip lines, custom NA, custom delimiter.
Show solution
Exercise 5.2: Read multiple files
Difficulty: Advanced. Use map_dfr.
Show solution
Exercise 5.3: Read large file in chunks
Difficulty: Advanced.
Show solution
Exercise 5.4: Read with progress
Difficulty: Intermediate.
Show solution
What to do next
- Data-Wrangling-Exercises (shipped), clean data after import.
- EDA-Exercises (shipped), explore the imported data.