Description Usage Arguments Details Value Author(s) References See Also Examples
Writes the data frame to file in the Stata XML format.
1 |
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. |
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.
NULL
Jeffrey Arnold
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.
read.stataXml
, asStataDate
, write.dta
, read.dta
1 2 3 | data(swiss)
write.stataXml(swiss,swissfile <- tempfile())
read.stataXml(swissfile)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.