找回密码
 注册
查看: 2964|回复: 0

R语言:write.dta()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 20:33:44 | 显示全部楼层 |阅读模式
write.dta(foreign)
write.dta()所属R语言包:foreign

                                        Write Files in Stata Binary Format
                                         写在Stata二进制格式的文件

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Writes the data frame to file in the Stata binary format.  Does not write array variables unless they can be drop-ed to a vector.
写入文件Stata的二进制格式的数据框。不写数组变量,除非他们可以drop-ED向量。


用法----------Usage----------


write.dta(dataframe, file, version = 7L,
          convert.dates = TRUE, tz = "GMT",
          convert.factors = c("labels", "string", "numeric", "codes"))



参数----------Arguments----------

参数:dataframe
a data frame.
一个数据框。


参数:file
character string giving filename.
给文件名字符串。


参数:version
integer: Stata version: 6, 7, 8 and 10 are supported, and 9 is mapped to 8, 11 to 10.
整数:Stata的版本:6,7,8和10的支持,并映射到8,11至10。


参数:convert.dates
Convert Date and POSIXt objects to Stata dates?
转换Date和POSIXt对象的Stata日期?


参数:tz
timezone for date conversion
时区转换为日期


参数:convert.factors
how to handle factors
如何处理因素


Details

详情----------Details----------

The major differences between file formats in Stata versions is that version 7.0 and later allow 32-character variable names (5 and 6 were restricted to 8-character name).  The abbreviate function is used to trim long variables to the permitted length.  A warning is given if this is needed and it is an error for the abbreviated names not to be unique.
在Stata版本的文件格式之间的主要差别是,7.0版和以后允许32个字符的变量名(5和6只限于8个字符的名称)。 abbreviate函数是用来修剪长变量允许的长度。如果这是需要给出一个警告,它是一个错误不是唯一的缩写名称。

The columns in the data frame become variables in the Stata data set. Missing values are handled correctly.
在数据框成为Stata数据集变量列。正确处理缺失值。

Unless deselected by argument convert.dates, R date and date-time objects (POSIXt classes) are converted into the Stata format.  For date-time objects this may lose information – Stata dates are in days since 1960-1-1.  POSIXct objects can be written without conversion but will not be understood as dates by Stata; POSIXlt objects cannot be written without conversion.
除非取消由参数convert.dates,R日期和日期时间对象(POSIXt类)的Stata格式转换成。对于日期时间的对象,这可能会丢失信息 -  Stata的日期自1960年1月1日起,天。 POSIXct对象可以被写入,无需转换,但不会被理解为日期由Stata的POSIXlt对象不能写,无需转换。

There are four options for handling factors.  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.
处理的因素有四个选项。默认是使用Stata的价值标签的因子水平。 convert.factors="string",因子水平作为字符串写入。 convert.factors="numeric"水平的数值被写入,或NA如果他们不能被强制转换为数字。最后,convert.factors="codes"写基本因素的整数代码。最后这是唯一可用的方法和主要用于提供向后兼容性。

For Stata 8 or later use the default version=7 – the only advantage of Stata 8 format is that it can represent multiple different missing value types, and R doesn't have them.  Stata 10/11 allows longer format lists, but R does not make use of them.
对于Stata的8或更高版本使用默认version=7 -  Stata的8格式的,唯一的好处是,它可以代表多种不同缺少的值类型,和R没有他们。 10/11的Stata允许较长的格式列表,但R不使用它们。

Note that the Stata formats are documented to use ASCII strings – R does not enforce this, but use of non-ASCII character strings will not be portable as the encoding is not recorded.  Up to 244 bytes are allowed in character data, and longer strings will be truncated with a warning.
请注意,Stata的格式记录使用ASCII字符串 -  R不执行,但没有记录编码,使用非ASCII字符的字符串将不能移植。允许最多244个字节的字符数据,和更长的字符串将被截断警告。

Stata uses some large numerical values to represent missing values.  This function does not currently check, and hence integers greater than 2147483620 and doubles greater than 8.988e+307 may be misinterpreted by Stata.
Stata的使用,一些大的数值来表示遗漏值。此功能目前并不检查,因此整数比2147483620和双打比8.988e+307可Stata的误解更大。


值----------Value----------

NULL
NULL


作者(S)----------Author(s)----------


Thomas Lumley and R-core members



参考文献----------References----------

help (version 8 and later, also http://www.stata.com/help.cgi?dta and http://www.stata.com/help.cgi?dta_113) describe the file formats.

参见----------See Also----------

read.dta, attributes, DateTimeClasses, abbreviate
read.dta,attributes,DateTimeClasses,abbreviate


举例----------Examples----------


write.dta(swiss, swissfile <- tempfile())
read.dta(swissfile)

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-24 08:43 , Processed in 0.025648 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表