Data Import

How Can I Read Data Into R?

To read and write Excel files from R, click here. To read and write SPSS, SAS and Stata files from R, click here. To read and write text files from R, click here.

Reading and Writing Excel Files With R Using readxl and writexl

This tutorial walks you through how to use the readxl package to read Microsoft Excel .xls and .xlsx file formats into R, and how to export data from R back out to an Excel format using the writexl package. readxl’s functions are related to importing Excel files into a tibble object, which is modern R’s internal data format. A tibble can then be manipulated to create summary tables or plots, run statistical tests, or perform other common analysis tasks.
Read more

Reading SAS, SPSS, or Stata files into R using haven

One of the biggest benefits of using R is its flexibility in working with various types of data used by other statistical software. If you are collaborating with other researchers, they may be working with data produced by SAS (.sas7bdat), SPSS (.sav), or Stata (.dta). The haven package in R was developed specifically to import and export data in these formats. Similar to readr for rectangular text data, haven’s functions read files in these formats into a tibble object in R.
Read more

Reading Rectangular Data Into R Using readr

The first step of an analysis in R is to read in your data. Data files can come in many different formats, but are commonly in a plain-text rectangular format such as .csv, .tsv, or .txt. The readr package allows you to read in such files. Most of readr’s functions are related to turning flat files into a tibble object, which is modern R’s internal data format. A tibble can then be manipulated to create summary tables or plots, run statistical tests, or perform other common analysis tasks.
Read more