read.dta {foreign} | R Documentation |
Reads a file in Stata version 5-7 or 7/SE binary format into a dataframe.
read.dta(file, convert.dates=TRUE,tz="GMT",convert.factors=TRUE)
file |
a filename as a character string. |
convert.dates |
Convert Stata dates to POSIXct class? |
tz |
timezone for date conversion |
convert.factors |
Use Stata value labels to create factors? (version 6.0 or later) |
The variables in the Stata data set become the columns of the data frame. Missing values are correctly handled. The data label, variable labels, and timestamp are stored as attributes of the data frame. Nothing is done with variable characteristics.
Optionally, Stata dates (%d formats) are converted to R's
POSIXct
class and variables with Stata value labels are
converted to factors. In any case the value label and format
information is stored as attributes on the returned data frame.
a data frame
Thomas Lumley
Stata Users Manual (versions 5 & 6) and Programming manual (version 7) describe the format of the files
write.dta
,
attributes
DateTimeClasses
factor
data(swiss) write.dta(swiss,swissfile<-tempfile()) read.dta(swissfile)