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.
read.dta(file, use.value.labels = FALSE, formats = FALSE, label = FALSE, labels = FALSE,
missing = FALSE, widths = FALSE, as.data.frame = TRUE, check = TRUE)
Returns a data frame or tibble.
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"
.
logical: if TRUE
, variables with value labels
are converted into factors.
logical: if TRUE
(default), variable formats are
shown in an attribute for all variables.
logical: if TRUE
, variable labels are
shown in an attribute for all variables.
logical: if TRUE
, value labels are
shown in an attribute for all variables.
logical: if TRUE
, convert tagged missing values
to regular R NA
.
logical: if TRUE
, widths are shown in an attribute
for all variables.
logical: if TRUE
(default), function returns a
regular data frame;
if FALSE
function returns a tibble.
logical: if TRUE
(default), argument specification
is checked.
Hadley Wickham and Evan Miller
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
read.sav
, write.sav
, read.xlsx
,
write.xlsx
, read.mplus
, write.mplus
if (FALSE) {
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)
}
Run the code above in your browser using DataLab