write.stataXml: Write Files in Stata XML Format

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Writes the data frame to file in the Stata XML format.

Usage

1
write.stataXml(dataframe, file, convert.factors = "labels", sortlist = character(), fmtlist = NULL, typelist = NULL, datalabel = "Written by R.", variableLabels = rep("", ncol(dataframe)), char = list(), verbose = FALSE, double = TRUE)

Arguments

dataframe

data frame.

file

character: filename.

convert.factors

character. how to handle factors.

sortlist

character. variables the data frame is sorted by.

fmtlist

character. formats for each variable.

typelist

character. Stata data type of each variable.

datalabel

character. Data set label.

variableLabels

character. Variable labels.

char

list of character vectors. Variable characteristics to be used by Stata, including notes.

verbose

logical. Write xml in a more human readable form. Equivalent to the legible option in the Stata command xmluse.

double

logical. Convert numerical vectors to double, else convert to float.

Details

The Stata XML format was introduced in Stata 9 as an alternative to the binary .dta format to store datasets. This format can be written by the Stata command xmlsave, doctype(dta), and read by the Stata command xmluse. A file in Stata xml format contains the same information contained in the Stata binary .dta files.

The columns in the data frame become variables in the Stata data set. Missing values are correctly handled.

Unless deselected, R date and data-time objects will be converted into the Stata format using asStataTime.

There are four options for handling factors (the same as in write.dta.) The default is to use Stata "value labels" for the factor levels. With convert.factors="string", the factor levels are written as strings. With convert.factors="numeric" the numeric values of the levels are written, or NA if they cannot be coerced to numeric. Finally, convert.factors="codes" writes the underlying integer codes of the factors. This last used to be the only available method and is provided largely for backwards compatibility.

Value

NULL

Author(s)

Jeffrey Arnold

References

Stata help for xmlsave. Online at http://www.stata.com/help.cgi?xmlsave. The XML format used by Stata has all the components of the binary Stata data format described in http://www.stata.com/help.cgi?dta.

See Also

read.stataXml, asStataDate, write.dta, read.dta

Examples

1
2
3
data(swiss)
write.stataXml(swiss,swissfile <- tempfile())
read.stataXml(swissfile)

jrnold/stataXml documentation built on May 20, 2019, 2:06 a.m.