read.dta {misty}R Documentation

Read Stata DTA File

Description

This function calls the read_dta function in the haven package by Hadley Wickham, Evan Miller and Danny Smith (2023) to read a Stata DTA file.

Usage

read.dta(file, use.value.labels = FALSE, formats = FALSE, label = FALSE, labels = FALSE,
         missing = FALSE,   widths = FALSE, as.data.frame = TRUE, check = TRUE)

Arguments

file

a character string indicating the name of the Stata data file with or without file extension '.dta', e.g., "Stata_Data.dta" or "Stata_Data".

use.value.labels

logical: if TRUE, variables with value labels are converted into factors.

formats

logical: if TRUE (default), variable formats are shown in an attribute for all variables.

label

logical: if TRUE, variable labels are shown in an attribute for all variables.

labels

logical: if TRUE, value labels are shown in an attribute for all variables.

missing

logical: if TRUE, convert tagged missing values to regular R NA.

widths

logical: if TRUE, widths are shown in an attribute for all variables.

as.data.frame

logical: if TRUE (default), function returns a regular data frame; if FALSE function returns a tibble.

check

logical: if TRUE (default), argument specification is checked.

Value

Returns a data frame or tibble.

Note

This function is a modified copy of the read_dta() function in the haven package by Hadley Wickham, Evan Miller and Danny Smith (2023).

Author(s)

Hadley Wickham and Evan Miller

References

Wickham H, Miller E, Smith D (2023). haven: Import and Export 'SPSS', 'Stata' and 'SAS' Files. R package version 2.5.3. https://CRAN.R-project.org/package=haven

See Also

read.sav, write.sav, read.xlsx, write.xlsx, read.mplus, write.mplus

Examples

## Not run: 

read.dta("Stata_Data.dta")
read.dta("Stata_Data")

# Example 2: Read Stata data, convert variables with value labels into factors
read.dta("Stata_Data.dta", use.value.labels = TRUE)

# Example 3: Read Stata data as tibble
read.dta("Stata_Data.dta", as.data.frame = FALSE)

## End(Not run)

[Package misty version 0.6.3 Index]