readr
Read flat files (csv, tsv, fwf) into R
readr is an R package that provides fast, user-friendly functions for reading rectangular data from delimited files like CSV and TSV. It’s designed to parse diverse real-world data formats while providing clear diagnostic messages when parsing encounters unexpected results.
The package automatically guesses column types during exploratory work but encourages explicit type specifications for production code. It’s significantly faster than base R (up to 10-100x), handles strings and dates more sensibly by default, and follows tidyverse conventions for consistency across workflows. Since version 2.0.0, it uses the vroom parsing engine for improved performance.
Contributors#
Resources featuring readr#
R-Ladies Rome (English) - What’s new in the tidyverse - Isabella Velasquez
Welcome to R-Ladies Rome Chapter!
What’s new in the tidyverse - Speaker: Isabella Velasquez
In this video, Isabella will tell you about What’s new in the tidyverse, a suite of packages that’s revolutionized data wrangling, visualization, and analysis. Recently, Tidyverse has undergone some changes and updates to make it even more user-friendly and powerful. The changes to Tidyverse include new packages, updates to existing ones, and improvements in performance and functionality. Some of the most notable updates include enhancements to package dependencies, performance improvements for specific functions such as group_by(), and the addition of new packages such as ggplot2, readr and dplyr.
You can find the latest news here: https://bit.ly/3z9BcMR To follow Isabella Velásquez: Twitter: twitter.com/ivelasq3 LinkedIn: linkedin.com/in/ivelasq/
Materials: GitHub repo: https://bit.ly/3LHVSmS Website: https://bit.ly/3M5gE03 The tidyverse blog: https://www.tidyverse.org/blog/
Hadley Wickham | testthat 3.0.0 | RStudio (2020)
In this webinar, I’ll introduce some of the major changes coming in testthat 3.0.0. The biggest new idea in testthat 3.0.0 is the idea of an edition. You must deliberately choose to use the 3rd edition, which allows us to make breaking changes without breaking old packages. testthat 3e deprecates a number of older functions that we no longer believe are a good idea, and tweaks the behaviour of expect_equal() and expect_identical() to give considerably more informative output (using the new waldo package).
testthat 3e also introduces the idea of snapshot tests which record expected value in external files, rather than in code. This makes them particularly well suited to testing user output and complex objects. I’ll show off the main advantages of snapshot testing, and why it’s better than our previous approaches of verify_output() and expect_known_output().
Finally, I’ll go over a bunch of smaller quality-of-life improvements, including tweaks to test reporting and improvements to expect_error(), expect_warning() and expect_message().
Webinar materials: https://rstudio.com/resources/webinars/testthat-3/
About Hadley: Hadley Wickham is the Chief Scientist at RStudio, a member of the R Foundation, and Adjunct Professor at Stanford University and the University of Auckland. He builds tools (both computational and cognitive) to make data science easier, faster, and more fun. You may be familiar with his packages for data science (the tidyverse: including ggplot2, dplyr, tidyr, purrr, and readr) and principled software development (roxygen2, testthat, devtools, pkgdown). Much of the material for the course is drawn from two of his existing books, Advanced R and R Packages, but the course also includes a lot of new material that will eventually become a book called “Tidy tools”

Reproducible Examples with the reprex package
Reproducible Examples and the reprex package.
https://speakerdeck.com/jennybc/reprex-reproducible-examples-with-r
Jump to: 0:08 Intro 0:40 Basic usage of reprex 3:35 Motivation, why use reprex? “Help me help you”
4:08 Define reprex?
Three commons ways to use the term.
- noun, a reproducible example
- the reprex package. a tool to build R
reprexs - reprex::reprex(), a function in
reprexto make a reprex.
5:26 When should you use a reprex?
6:14 reprex installation and setup. How do you actually get repex on your machine? 7:59 Advanced setup and discussion. 9:45 Please use advanced features responsibly.
11:02 Why does the reprex package exist? Anyone who has helped teach R or dealt with github issues, twitter, stack overflow & RStudio community questions knows that helping people diagnose their coding problems can be hard. This tool comes from hard-won experience. It’s aim to is help people ask well formed questions and increase the chances of getting well formed answers quickly.
12:52 philosophy behind reprex
- code that I can run
- code that I don’t need to run
- code that I can easily run
13:52 code that I can run.
17:25 Tips on writing good reprexs. Dos and don’ts.
18:52 How do I get my data into my reprex?
Getting small data and CSV type data into your reprex is easy.
“I have a big hairy data object and I can only show their problem by using it”, but that’s not always the case.
21:02 code that I don’t need to run reprex gives your reader the code and reveals the output being produced by that code. For experienced coders, that might be enough to help you.
22:44 code that I can easily run Don’t copy and paste from the R console. This is usually annoying for your reader. Worse than console copy-pasta is the screenshot. (Many people think screenshots of code are downright offensive.)
25:03 reprex_clean If you copy someone else’s reprex into your consolve, it may include their output, making your new reprex a untidy. Here are tips for taking someone else’s reprex code and output, and create a clean reprex reply.
25:54 shock and awe More interesting features of the reprex package.
- 26:29 What about figures and plots in your reprex? So happy you asked about that. reprex will automatically upload your images to imgur.com.
- 28:23 Create a reprex by explicitly providing your code in the reprex call.
- 29:00 when you need your reprex to work in the current working directory.
- 30:45 Differently flavored markdown. Optimize your reprex markdown output for github, stack overflow, or the RStudio community.
- 30:31 Make your reprex create an R script, with your reprex outputs as comments. This is handy for pasting into an email or slack-type-app.
- 32:25 Rich text format, rtf output. (currently experimental feature as of this video)
- 33:06 supress the reprex add at the bottom of your reprex
- 33:19 Include session info.
- 33:54 Auto styling of your code. Good if you’re dealing with poorly formatting code.
- 34:25 Change your comments string.
- 34:32 Silence Tidyverse startup messages.
- 35:00 Capture a reprex that sends messages to standard output and standard input (e.g. package installation compilation messages).
36:13 Set up personal defaults for your reprex usage.
36:54 reprex RStudio addins; render reprex and reprex selection. These accelerate your use of reprex.
39:01 The human side of reproducible examples. How to ask questions in ways that are most likely to get answered. Sorry for the tough love, but this is important. Why are you always asked to give a reprex?
- Experts try to use reproducible examples to ensure their advice works.
- Making a good reprex is hard. But, you are asking them to solve a problem for you, so meet them halfway.
- Creating reprexes is good coding practice.
- Making a good reprex is often a good way to debug your issue in the embarrassment-free privacy of your own home.
- reprexes lead to discussions more likely to help people in the future.
44:34 Behind the scenes of reprex
44:44 Thanks for those that helped make reprex possible.
Questions and Answers
- 46:05 can reprex capture variables and objects in the current environment? (not yet, maybe in development)
- 47:25 does reprex actually check that the code is self contained? (self contained)
- 48:08 does readr::read_csv support the text argument? (yep, just read the help manual for readr)
