Import STATA dataset as data frame into R

Share:

Description

Imports data from STATA dta-files, including NA's, value and variable labels.

Usage

1
read_stata(path, atomic.to.fac = FALSE, enc = NULL)

Arguments

path

File path to the data file.

atomic.to.fac

Logical, if TRUE, categorical variables imported from the dataset (which are imported as atomic) will be converted to factors.

enc

The character encoding used for the file. This defaults to the encoding specified in the file, or UTF-8. Use this argument to override the default encoding stored in the file.

Value

A data frame containing the STATA data. Retrieve value labels with get_labels and variable labels with get_label.

Note

This is a wrapper function for read_dta function of the haven package. This function converts the imported data into a common class format (see unlabel).

See Also

read_spss

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.