TIDYVERSE | DPLYR

R Functions: read_csv()

The best way to import CSV data into R

Josh Gonzales, PhD(c)
R Tutorials
Published in
3 min readMar 21, 2020

--

We talk about R functions that will make your data science journey easier.

Having a bunch of data is nice, but the real fun starts when you load that data into a program that can interpret what’s going on. The most common way to get data into R is the read.csv function. However, I suggest you use read_csv instead.

Here’s why, and how to do it.

What’s the difference?

Sometimes in coding, the difference between a dot and an underscore is little more than a coder’s preference. In this case, however, that subtle change means everything.

The read_csv function imports data into R as a tibble, while read.csv imports a regular old R data frame instead.

Tibbles are better than regular data frames because they:

  • load faster
  • don’t change input types
  • allow you to have columns as lists
  • allow non-standard variable names (i.e. your variables can start with a number and can contain spaces)
  • never create row names

--

--

Josh Gonzales, PhD(c)
R Tutorials

PhD Candidate @ University of Guelph studying representation in entertainment and goal-oriented decision-making