R for Stata users

Read datasets in R

Make sure you have version of R >= 3.3.0 and install the packages tidyverse and rio

install.packages("tidyverse")
install.packages("rio")

The functions export() and import() in the rio package automatically choose the appropriate data read or write function based on file extension

Read flat files

library(rio)

Open a .csv:

Stata import delimited "filepath.csv"
R import("filepath.csv")

Save a .csv:

Stata export delimited using "newfilepath.csv", delimiters("\t")
R export(df, "newfilepath.csv")

Read excel files

Stata import excel "filepath.xls"
R import("filepath.xls")

Read SAS or Stata files

library(rio)
# import Stata datasets
df <- import("http://www.nber.org/namcs/data/namcs2010.dta")
# import SAS datasets
df <- import("http://www.nber.org/namcs/data/namcs2010.sas7bdat")

Which file format to use in R?

Store your R dataframes in the feather format.

export("filepath.feather")

R also has proprietary formats like .rda and rds, but they are slower.